1# Copyright 2014-2015, Max Planck Society. 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without modification, 5# are permitted provided that the following conditions are met: 6# 7# 1. Redistributions of source code must retain the above copyright notice, 8# this list of conditions and the following disclaimer. 9# 10# 2. Redistributions in binary form must reproduce the above copyright notice, 11# this list of conditions and the following disclaimer in the documentation 12# and/or other materials provided with the distribution. 13# 14# 3. Neither the name of the copyright holder nor the names of its contributors 15# may be used to endorse or promote products derived from this software without 16# specific prior written permission. 17# 18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27# OF THE POSSIBILITY OF SUCH DAMAGE. 28 29# File created by Raffi Enficiaud 30 31set(thirdparty_dir ${CMAKE_SOURCE_DIR}/thirdparty) 32 33# the location where the archives will be deflated 34set(thirdparties_deflate_directory ${CMAKE_BINARY_DIR}/external_libs_deflate) 35if(NOT EXISTS ${thirdparties_deflate_directory}) 36 file(MAKE_DIRECTORY ${thirdparties_deflate_directory}) 37endif() 38 39 40 41# custom cmake packages, should have lower priority than the ones bundled with cmake 42set(CMAKE_MODULE_PATH 43 ${CMAKE_MODULE_PATH} 44 ${CMAKE_SOURCE_DIR}/cmake_modules/ ) 45 46 47 48# these variables allow to specify to which the main project will link and 49# to potentially copy some resources to the output directory of the main project. 50# They are used by the CMakeLists.txt calling this file. 51 52set(PHD_LINK_EXTERNAL) # target to which the phd2 main library will link to 53set(PHD_COPY_EXTERNAL_ALL) # copy of a file for any configuration 54set(PHD_COPY_EXTERNAL_DBG) # copy for debug only 55set(PHD_COPY_EXTERNAL_REL) # copy for release only 56 57 58# this module will be used to find system installed libraries on Linux 59if(UNIX AND NOT APPLE) 60 find_package(PkgConfig) 61endif() 62 63 64# 65# copies the dependency files into the target output directory 66# 67macro(copy_dependency_with_config target_name dependency_list_all dependency_list_dbg dependency_list_release) 68 69 70 set(dependency_list_dbg_with_all ${${dependency_list_dbg}} ${${dependency_list_all}}) 71 set(dependency_list_dbg_with_all_cleaned) 72 foreach(_element ${dependency_list_dbg_with_all}) 73 if(NOT EXISTS ${_element}) 74 message(FATAL_ERROR "Dependency ${_element} does not exist") 75 endif() 76 #message(STATUS "copyX ${_element}") 77 get_filename_component(_element1 ${_element} REALPATH) 78 set(dependency_list_dbg_with_all_cleaned ${dependency_list_dbg_with_all_cleaned} ${_element1}) 79 unset(_element1) 80 endforeach() 81 82 list(REMOVE_DUPLICATES dependency_list_dbg_with_all_cleaned) 83 set(dependency_list_dbg_with_all ${dependency_list_dbg_with_all_cleaned}) 84 unset(dependency_list_dbg_with_all_cleaned) 85 unset(_element) 86 87 foreach(_element ${dependency_list_dbg_with_all}) 88 get_filename_component(_element_name ${_element} NAME) 89 add_custom_command( 90 TARGET ${target_name} 91 PRE_BUILD 92 COMMAND ${CMAKE_COMMAND} -E 93 $<$<CONFIG:Debug>:echo> 94 $<$<CONFIG:Debug>:"Copy ${_element_name} to $<TARGET_FILE_DIR:${target_name}>/."> 95 $<$<NOT:$<CONFIG:Debug>>:echo_append> 96 $<$<NOT:$<CONFIG:Debug>>:"."> 97 COMMAND ${CMAKE_COMMAND} -E 98 $<$<CONFIG:Debug>:copy_if_different> 99 $<$<CONFIG:Debug>:${_element}> 100 $<$<CONFIG:Debug>:$<TARGET_FILE_DIR:${target_name}>/.> 101 $<$<NOT:$<CONFIG:Debug>>:echo_append> 102 $<$<NOT:$<CONFIG:Debug>>:""> 103 COMMENT "Copy ${target_name} dependencies into the output folder") 104 105 106 107 #message(STATUS "copy ${_element_name}") 108 # add_custom_command( 109 # TARGET ${target_name} 110 # PRE_BUILD 111 # COMMAND ${CMAKE_COMMAND} -E echo Copy ${_element_name} into $<TARGET_FILE_DIR:${target_name}>/. 112 113 # COMMAND ${CMAKE_COMMAND} -E $<$<CONFIG:Debug>:copy_if_different>$<$<NOT:$<CONFIG:Debug>>:echo> ${_element} $<TARGET_FILE_DIR:${target_name}>/. 114 # COMMENT "Copy ${target_name} dependencies into the output folder") 115 116 unset(_element_name) 117 endforeach() 118 unset(dependency_list_dbg_with_all) 119 unset(_element) 120 121 122 set(dependency_list_release_with_all ${${dependency_list_release}} ${${dependency_list_all}}) 123 set(dependency_list_release_with_all_cleaned) 124 foreach(_element ${dependency_list_release_with_all}) 125 if(NOT EXISTS ${_element}) 126 message(FATAL_ERROR "Dependency ${_element} does not exist") 127 endif() 128 get_filename_component(_element1 ${_element} REALPATH) 129 set(dependency_list_release_with_all_cleaned ${dependency_list_release_with_all_cleaned} ${_element1}) 130 unset(_element1) 131 endforeach() 132 list(REMOVE_DUPLICATES dependency_list_release_with_all_cleaned) 133 set(dependency_list_release_with_all ${dependency_list_release_with_all_cleaned}) 134 unset(dependency_list_release_with_all_cleaned) 135 unset(_element) 136 137 foreach(_element ${dependency_list_release_with_all}) 138 get_filename_component(_element_name ${_element} NAME) 139 add_custom_command( 140 TARGET ${target_name} 141 PRE_BUILD 142 COMMAND ${CMAKE_COMMAND} -E 143 $<$<CONFIG:Release>:echo> #$<$<NOT:$<CONFIG:Release>>:echo> ${_element} $<TARGET_FILE_DIR:${target_name}>/. 144 $<$<CONFIG:Release>:"Copy ${_element_name} to $<TARGET_FILE_DIR:${target_name}>/."> 145 $<$<NOT:$<CONFIG:Release>>:echo_append> 146 $<$<NOT:$<CONFIG:Release>>:"."> 147 COMMAND ${CMAKE_COMMAND} -E 148 $<$<CONFIG:Release>:copy_if_different> 149 $<$<CONFIG:Release>:${_element}> 150 $<$<CONFIG:Release>:$<TARGET_FILE_DIR:${target_name}>/.> 151 $<$<NOT:$<CONFIG:Release>>:echo_append> 152 $<$<NOT:$<CONFIG:Release>>:""> 153 COMMENT "Copy ${target_name} dependencies into the output folder") 154 unset(_element_name) 155 endforeach() 156 unset(dependency_list_release_with_all) 157 unset(_element) 158 159 # we can also use this thing to install external stuff 160 #install( FILES ${dependency_name_debug} 161 # DESTINATION bin 162 # CONFIGURATIONS Debug) 163 #install( FILES ${dependency_name_non_debug} 164 # DESTINATION bin 165 # CONFIGURATIONS Release) 166 167 168endmacro(copy_dependency_with_config) 169 170if(APPLE) 171 find_library(quicktimeFramework QuickTime) 172 find_library(iokitFramework IOKit) 173 find_library(carbonFramework Carbon) 174 find_library(cocoaFramework Cocoa) 175 find_library(systemFramework System) 176 find_library(webkitFramework Webkit) 177 find_library(audioToolboxFramework AudioToolbox) 178 find_library(openGLFramework OpenGL) 179 find_library(coreFoundationFramework CoreFoundation) 180endif() 181 182# 183# external rules common to all platforms 184# 185############################################# 186 187 188############################################## 189# cfitsio 190 191if(USE_SYSTEM_CFITSIO) 192 find_package(CFITSIO REQUIRED) 193 include_directories(${CFITSIO_INCLUDE_DIR}) 194 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${CFITSIO_LIBRARIES}) 195 message(STATUS "Using system's CFITSIO.") 196else(USE_SYSTEM_CFITSIO) 197 198 set(CFITSIO_MAJOR_VERSION 3) 199 set(CFITSIO_MINOR_VERSION 47) 200 set(CFITSIO_VERSION ${CFITSIO_MAJOR_VERSION}.${CFITSIO_MINOR_VERSION}) 201 202 set(libcfitsio_root ${thirdparties_deflate_directory}/cfitsio-${CFITSIO_VERSION}) 203 204 if(NOT EXISTS ${libcfitsio_root}) 205 # untar the dependency 206 message(STATUS "[thirdparty] untarring cfitsio") 207 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${thirdparty_dir}/cfitsio-${CFITSIO_VERSION}-patched.tar.gz 208 WORKING_DIRECTORY ${thirdparties_deflate_directory}) 209 endif() 210 211 # copied and adapted from the CMakeLists.txt of cftsio project. The sources of the project 212 # are left untouched 213 214 file(GLOB CFTSIO_H_FILES "${libcfitsio_root}/*.h") 215 216 # OpenPhdGuiding COMMENT HERE 217 # Raffi: these should also be cleaned (link against zlib of the system) 218 219 set(CFTSIO_SRC_FILES 220 buffers.c cfileio.c checksum.c drvrfile.c drvrmem.c 221 drvrnet.c drvrsmem.c drvrgsiftp.c editcol.c edithdu.c eval_l.c 222 eval_y.c eval_f.c fitscore.c getcol.c getcolb.c getcold.c getcole.c 223 getcoli.c getcolj.c getcolk.c getcoll.c getcols.c getcolsb.c 224 getcoluk.c getcolui.c getcoluj.c getkey.c group.c grparser.c 225 histo.c iraffits.c 226 modkey.c putcol.c putcolb.c putcold.c putcole.c putcoli.c 227 putcolj.c putcolk.c putcoluk.c putcoll.c putcols.c putcolsb.c 228 putcolu.c putcolui.c putcoluj.c putkey.c region.c scalnull.c 229 swapproc.c wcssub.c wcsutil.c imcompress.c quantize.c ricecomp.c 230 pliocomp.c fits_hcompress.c fits_hdecompress.c zlib/zuncompress.c 231 zlib/zcompress.c zlib/adler32.c zlib/crc32.c zlib/inffast.c 232 zlib/inftrees.c zlib/trees.c zlib/zutil.c zlib/deflate.c 233 zlib/infback.c zlib/inflate.c zlib/uncompr.c simplerng.c 234 f77_wrap1.c f77_wrap2.c f77_wrap3.c f77_wrap4.c 235 ) 236 237 foreach(_src_file IN LISTS CFTSIO_SRC_FILES) 238 set(CFTSIO_SRC_FILES_rooted "${CFTSIO_SRC_FILES_rooted}" ${libcfitsio_root}/${_src_file}) 239 endforeach() 240 241 add_library(cfitsio STATIC ${CFTSIO_H_FILES} ${CFTSIO_SRC_FILES_rooted}) 242 target_include_directories(cfitsio PUBLIC ${libcfitsio_root}/) 243 244 # OpenPhdGuiding MODIFICATION HERE: we link against math library only on UNIX 245 if(UNIX) 246 target_link_libraries(cfitsio m) 247 endif() 248 249 # OpenPhdGuiding MODIFICATION HERE: suppress warning about unused function result 250 if(UNIX AND NOT APPLE) 251 set_target_properties(cfitsio PROPERTIES COMPILE_FLAGS "-Wno-unused-result") 252 # Raffi: use target_compile_options ? 253 endif() 254 255 if(WIN32) 256 target_compile_definitions( 257 cfitsio 258 PRIVATE BUILDING_CFITSIO 259 PRIVATE FF_NO_UNISTD_H 260 PRIVATE _CRT_SECURE_NO_WARNINGS 261 PRIVATE _CRT_SECURE_NO_DEPRECATE) 262 endif() 263 264 set_target_properties(cfitsio PROPERTIES 265 VERSION ${CFITSIO_VERSION} 266 SOVERSION ${CFITSIO_MAJOR_VERSION} 267 FOLDER "Thirdparty/") 268 269 270 # indicating the link and include directives to the main project. 271 # already done by the directive target_include_directories(cfitsio PUBLIC 272 # include_directories(${libcfitsio_root}) 273 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} cfitsio) 274 275endif(USE_SYSTEM_CFITSIO) 276 277 278 279 280############################################## 281# VidCapture 282 283if(WIN32) 284 285 set(libvidcap_root ${thirdparty_dir}/VidCapture) 286 287 # copied and adapted from the CMakeLists.txt of cftsio project. The 288 # sources of the project are left untouched 289 290 file(GLOB VIDCAP_H_FILES "${libvidcap_root}/Source/CVCommon/*.h" "${libvidcap_root}/Source/VidCapture/*.h") 291 292 set(VIDCAP_SRC_FILES 293 Source/VidCapture/CVImage.cpp 294 Source/VidCapture/CVImageGrey.cpp 295 Source/VidCapture/CVImageRGB24.cpp 296 Source/VidCapture/CVImageRGBFloat.cpp 297 Source/VidCapture/CVVidCapture.cpp 298 Source/VidCapture/CVVidCaptureDSWin32.cpp 299 Source/VidCapture/CVDShowUtil.cpp 300 Source/VidCapture/CVFile.cpp 301 Source/VidCapture/CVPlatformWin32.cpp 302 Source/VidCapture/CVTraceWin32.cpp 303 ) 304 305 foreach(_src_file IN LISTS VIDCAP_SRC_FILES) 306 set(VIDCAP_SRC_FILES_rooted "${VIDCAP_SRC_FILES_rooted}" ${libvidcap_root}/${_src_file}) 307 endforeach() 308 309 add_library(VidCapture STATIC ${VIDCAP_H_FILES} ${VIDCAP_SRC_FILES_rooted}) 310 target_include_directories(VidCapture PUBLIC ${libvidcap_root}/Source/CVCommon ${libvidcap_root}/Source/VidCapture) 311 312 target_compile_definitions( 313 VidCapture 314 PRIVATE FF_NO_UNISTD_H 315 PRIVATE _CRT_SECURE_NO_WARNINGS 316 PRIVATE _CRT_SECURE_NO_DEPRECATE) 317 318 set_target_properties(VidCapture PROPERTIES 319 FOLDER "Thirdparty/") 320 321 # indicating the link and include directives to the main project. 322 # already done by the directive target_include_directories(vidcap PUBLIC 323 # include_directories(${libvidcap_root}) 324 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} VidCapture) 325 326endif() 327 328 329 330 331############################################# 332# libusb: linux / apple 333 334if(NOT WIN32) 335 336set(LIBUSB libusb-1.0.21) 337set(libusb_root ${thirdparties_deflate_directory}/${LIBUSB}) 338set(USB_build TRUE) # indicates that the USB library is part of the project. Set to FALSE if already existing on the system 339set(LIBUSB_static TRUE) # true for static lib, dynamic lib otherwise 340 341if(NOT EXISTS ${libusb_root}) 342 # untar the dependency 343 execute_process( 344 COMMAND ${CMAKE_COMMAND} -E tar xf ${thirdparty_dir}/${LIBUSB}.tar.bz2 345 WORKING_DIRECTORY ${thirdparties_deflate_directory}) 346endif() 347 348set(libusb_dir ${libusb_root}/libusb) 349# core files 350set(libUSB_SRC 351 ${libusb_dir}/core.c 352 ${libusb_dir}/descriptor.c 353 ${libusb_dir}/hotplug.c 354 ${libusb_dir}/io.c 355 ${libusb_dir}/sync.c 356 ${libusb_dir}/libusb.h 357 ${libusb_dir}/libusbi.h 358 ) 359 360# platform dependent files 361if(APPLE) 362 set(libUSB_SRC ${libUSB_SRC} 363 364 # platform specific configuration file 365 ${thirdparty_dir}/include/${LIBUSB} 366 367 # platform specific implementation 368 ${libusb_dir}/os/darwin_usb.h 369 ${libusb_dir}/os/darwin_usb.c 370 371 ${libusb_dir}/os/threads_posix.h 372 ${libusb_dir}/os/threads_posix.c 373 374 ${libusb_dir}/os/poll_posix.c 375 ) 376 set(${LIBUSB}_additional_compile_definition "OS_DARWIN=1") 377 set(${LIBUSB}_additional_include_dir ${thirdparty_dir}/include/${LIBUSB}) 378 # need to build a dynamic libusb since the ZWO SDK requires libusb 379 set(LIBUSB_static FALSE) 380elseif(WIN32) 381 set(libUSB_SRC ${libUSB_SRC} 382 383 # platform specific configuration files 384 ${libusb_root}/msvc/stdint.h 385 ${libusb_root}/msvc/inttypes.h 386 ${libusb_root}/msvc/config.h 387 388 # platform specific implementation 389 ${libusb_dir}/os/windows_winusb.h 390 ${libusb_dir}/os/windows_winusb.c 391 392 ${libusb_dir}/os/threads_windows.h 393 ${libusb_dir}/os/threads_windows.c 394 395 ${libusb_dir}/os/poll_windows.h 396 ${libusb_dir}/os/poll_windows.c 397 ) 398 set(${LIBUSB}_additional_compile_definition "OS_WINDOWS=1") 399 set(${LIBUSB}_additional_include_dir ${libusb_root}/msvc/) 400elseif(UNIX) 401 # libUSB is already an indirect requirement/dependency for phd2 (through libindi). 402 # I (Raffi) personally prefer having the same version 403 # for all platforms, but it should in theory always be better to link against existing libraries 404 # compiled and shipped by skilled people. 405 406 # this would find the libUSB module that is installed on the system. 407 # It requires "sudo apt-get install libusb-1.0-0-dev" 408 if(USE_SYSTEM_LIBUSB) 409 pkg_check_modules(USB_pkg libusb-1.0) 410 if(0) 411 message(FATAL_ERROR "libUSB not detected") 412 else() 413 include_directories(${USB_pkg_INCLUDE_DIRS}) 414 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${USB_pkg_LIBRARIES}) 415 set(USB_build FALSE) 416 set(usb_openphd ${USB_pkg_LIBRARIES}) 417 message(STATUS "Using system's libUSB.") 418 endif() 419 else(USE_SYSTEM_LIBUSB) 420 421 # in case the library is not installed on the system (as I have on my machines) 422 # try by building the library ourselves 423 424 set(libUSB_SRC ${libUSB_SRC} 425 426 # platform specific configuration file 427 ${thirdparty_dir}/include/${LIBUSB} 428 429 # platform specific implementation 430 ${libusb_dir}/os/linux_usbfs.c 431 ${libusb_dir}/os/linux_usbfs.h 432 ${libusb_dir}/os/linux_netlink.c 433 434 ${libusb_dir}/os/threads_posix.h 435 ${libusb_dir}/os/threads_posix.c 436 437 ${libusb_dir}/os/poll_posix.c 438 ) 439 440 set(${LIBUSB}_additional_compile_definition "OS_LINUX=1") 441 set(${LIBUSB}_additional_include_dir ${thirdparty_dir}/include/${LIBUSB}) 442 endif(USE_SYSTEM_LIBUSB) 443 444else() 445 message(FATAL_ERROR "libUSB unsupported platform") 446endif() 447 448if(${USB_build}) 449 include_directories(${libusb_dir}) 450 451 # libUSB compilation if OSX or Win32 or not installed on Linux 452 if(LIBUSB_static) 453 add_library(usb_openphd ${libUSB_SRC}) 454 else() 455 add_library(usb_openphd SHARED ${libUSB_SRC}) 456 # target_link_options requires newer cmake, so fall back to the old LINK_FLAGS target property 457 # target_link_options(usb_openphd -compatibility_version 2 -current_version 2) 458 set_target_properties(usb_openphd PROPERTIES LINK_FLAGS "-compatibility_version 2 -current_version 2") 459 if(APPLE32) 460 set(libUSB_link_objc "objc") 461 endif() 462 target_link_libraries(usb_openphd 463 ${coreFoundationFramework} 464 ${iokitFramework} 465 ${libUSB_link_objc} 466 ) 467 endif() 468 target_include_directories(usb_openphd PRIVATE ${${LIBUSB}_additional_include_dir}) 469 target_compile_definitions(usb_openphd PUBLIC ${${LIBUSB}_additional_compile_definition}) 470 set_property(TARGET usb_openphd PROPERTY FOLDER "Thirdparty/") 471 472 if(WIN32) 473 # silence the warnings on externals for win32 474 target_compile_definitions(usb_openphd PRIVATE _CRT_SECURE_NO_WARNINGS) 475 else() 476 target_compile_definitions(usb_openphd PRIVATE LIBUSB_DESCRIBE "") 477 endif() 478 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} usb_openphd) 479endif() 480 481endif() # NOT WIN32 482 483############################################# 484# libcurl 485############################################# 486 487if(WIN32) 488 set(libcurl_root ${thirdparties_deflate_directory}/libcurl) 489 set(libcurl_dir ${libcurl_root}/libcurl-7.54.0-win32) 490 if(NOT EXISTS ${libcurl_root}) 491 # unzip the dependency 492 file(MAKE_DIRECTORY ${libcurl_root}) 493 execute_process( 494 COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_SOURCE_DIR}/thirdparty/libcurl-7.54.0-win32.zip --format=zip 495 WORKING_DIRECTORY ${libcurl_root}) 496 endif() 497 include_directories(${libcurl_dir}/include) 498 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${libcurl_dir}/lib/LIBCURL.LIB) 499else() 500 if(APPLE) 501 # make sure to pick up the macos curl, not the mapcports curl in /opt/local/lib 502 find_library(CURL_LIBRARIES 503 NAMES curl 504 PATHS /usr/lib 505 NO_DEFAULT_PATH) 506 if(NOT CURL_LIBRARIES) 507 message(FATAL_ERROR "libcurl not found") 508 endif() 509 set(CURL_FOUND True) 510 set(CURL_INCLUDE_DIRS /usr/include) 511 else() 512 find_package(CURL REQUIRED) 513 endif() 514 message(STATUS "using libcurl ${CURL_LIBRARIES}") 515 include_directories(${CURL_INCLUDE_DIRS}) 516 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${CURL_LIBRARIES}) 517endif() 518 519############################################# 520# the Eigen library, mostly header only 521 522if(USE_SYSTEM_EIGEN3) 523 find_package(Eigen3 REQUIRED) 524 set(EIGEN_SRC ${EIGEN3_INCLUDE_DIR}) 525 message(STATUS "Using system's Eigen3.") 526else(USE_SYSTEM_EIGEN3) 527 set(EIGEN eigen-eigen-67e894c6cd8f) 528 set(eigen_root ${thirdparties_deflate_directory}/${EIGEN}) 529 if(NOT EXISTS ${eigen_root}) 530 # untar the dependency 531 execute_process( 532 COMMAND ${CMAKE_COMMAND} -E tar xjf ${thirdparty_dir}/${EIGEN}.tar.bz2 533 WORKING_DIRECTORY ${thirdparties_deflate_directory}) 534 endif() 535 536 set(EIGEN_SRC ${eigen_root}) 537endif(USE_SYSTEM_EIGEN3) 538 539 540############################################# 541# Google test, easily built 542 543if(USE_SYSTEM_GTEST) 544 find_package(GTest REQUIRED) 545 set(GTEST_HEADERS ${GTEST_INCLUDE_DIRS}) 546 message(STATUS "Using system's Gtest.") 547else(USE_SYSTEM_GTEST) 548 set(GTEST gtest-1.7.0) 549 set(gtest_root ${thirdparties_deflate_directory}/${GTEST}) 550 if(NOT EXISTS ${gtest_root}) 551 # unzip the dependency 552 execute_process( 553 COMMAND ${CMAKE_COMMAND} -E tar xzf ${thirdparty_dir}/${GTEST}.zip 554 WORKING_DIRECTORY ${thirdparties_deflate_directory}) 555 endif() 556 557 if(MSVC) 558 # do not replace default things, basically this line avoids gtest to replace 559 # default compilation options (which ends up with messing the link options) for the CRT 560 # As the name DOES NOT suggest, it does not force the shared crt. It forces the use of default things. 561 set(gtest_force_shared_crt ON CACHE INTERNAL "Gtest crt configuration" FORCE) 562 endif() 563 set(GTEST_HEADERS ${gtest_root}/include) 564 add_subdirectory(${gtest_root} tmp_cmakegtest) 565 set_property(TARGET gtest PROPERTY FOLDER "Thirdparty/") 566 set_property(TARGET gtest_main PROPERTY FOLDER "Thirdparty/") 567endif(USE_SYSTEM_GTEST) 568 569 570############################################# 571# wxWidgets 572# The usage is a bit different on all the platforms. For having version >= 3.0, a version of cmake >= 3.0 should be used on Windows (on Linux/OSX it works properly this way). 573if(WIN32) 574 # wxWidgets 575 set(wxWidgets_CONFIGURATION msw) 576 577 if(NOT wxWidgets_PREFIX_DIRECTORY OR NOT EXISTS ${wxWidgets_PREFIX_DIRECTORY}) 578 message(FATAL_ERROR "The variable wxWidgets_PREFIX_DIRECTORY should be defined and should point to a valid wxWindows installation path. See the open-phd-guiding wiki for more information.") 579 endif() 580 581 set(wxWidgets_ROOT_DIR ${wxWidgets_PREFIX_DIRECTORY}) 582 set(wxWidgets_USE_STATIC ON) 583 set(wxWidgets_USE_DEBUG ON) 584 set(wxWidgets_USE_UNICODE OFF) 585 find_package(wxWidgets REQUIRED COMPONENTS propgrid base core aui adv html net) 586 include(${wxWidgets_USE_FILE}) 587 #message(${wxWidgets_USE_FILE}) 588 589elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") 590 if(NOT DEFINED wxWidgets_PREFIX_DIRECTORY) 591 set(wxWidgets_PREFIX_DIRECTORY "/usr/local") 592 endif() 593 set(wxWidgets_CONFIG_OPTIONS --prefix=${wxWidgets_PREFIX_DIRECTORY}) 594 595 find_program(wxWidgets_CONFIG_EXECUTABLE 596 NAMES "wxgtk3u-3.1-config" 597 PATHS ${wxWidgets_PREFIX_DIRECTORY}/bin NO_DEFAULT_PATH) 598 if(NOT wxWidgets_CONFIG_EXECUTABLE) 599 message(FATAL_ERROR "Cannot find wxWidgets_CONFIG_EXECUTABLE from the given directory ${wxWidgets_PREFIX_DIRECTORY}") 600 endif() 601 602 set(wxRequiredLibs aui core base adv html net) 603 execute_process(COMMAND ${wxWidgets_CONFIG_EXECUTABLE} --libs ${wxRequiredLibs} 604 OUTPUT_VARIABLE wxWidgets_LIBRARIES 605 OUTPUT_STRIP_TRAILING_WHITESPACE) 606 separate_arguments(${wxWidgets_LIBRARIES}) 607 execute_process(COMMAND ${wxWidgets_CONFIG_EXECUTABLE} --cflags ${wxRwxRequiredLibs} 608 OUTPUT_VARIABLE wxWidgets_CXXFLAGS 609 OUTPUT_STRIP_TRAILING_WHITESPACE) 610 separate_arguments(wxWidgets_CXX_FLAGS UNIX_COMMAND "${wxWidgets_CXXFLAGS}") 611 separate_arguments(wxWidgets_LDFLAGS UNIX_COMMAND "${wxWidgets_LDFLAGS}") 612else() 613 if(wxWidgets_PREFIX_DIRECTORY) 614 set(wxWidgets_CONFIG_OPTIONS --prefix=${wxWidgets_PREFIX_DIRECTORY}) 615 616 find_program(wxWidgets_CONFIG_EXECUTABLE NAMES "wx-config" PATHS ${wxWidgets_PREFIX_DIRECTORY}/bin NO_DEFAULT_PATH) 617 if(NOT wxWidgets_CONFIG_EXECUTABLE) 618 message(FATAL_ERROR "Cannot find wxWidgets_CONFIG_EXECUTABLE from the given directory ${wxWidgets_PREFIX_DIRECTORY}") 619 endif() 620 endif() 621 622 find_package(wxWidgets REQUIRED COMPONENTS aui core base adv html net) 623 if(NOT wxWidgets_FOUND) 624 message(FATAL_ERROR "WxWidget cannot be found. Please use wx-config prefix") 625 endif() 626 #if(APPLE) 627 # set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} wx_osx_cocoau_aui-3.0) 628 #endif() 629 #message("wxLibraries ${wxWidgets_LIBRARIES}") 630endif() 631 632set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${wxWidgets_LIBRARIES}) 633 634 635############################################# 636# 637# INDI 638# 639############################################# 640 641if(WIN32) 642 set(indi_zip ${CMAKE_SOURCE_DIR}/thirdparty/indiclient-44aaf5d3-win32.zip) 643 set(indiclient_root ${thirdparties_deflate_directory}) 644 set(indiclient_dir ${indiclient_root}/indiclient) 645 if(NOT EXISTS ${indiclient_dir}) 646 message(STATUS "[thirdparty] untarring indiclient") 647 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${indi_zip} 648 WORKING_DIRECTORY ${indiclient_root}) 649 endif() 650 include_directories(${indiclient_dir}/include) 651 set(PHD_LINK_EXTERNAL_RELEASE ${PHD_LINK_EXTERNAL_RELEASE} ${indiclient_dir}/lib/indiclient.lib) 652 set(PHD_LINK_EXTERNAL_DEBUG ${PHD_LINK_EXTERNAL_DEBUG} ${indiclient_dir}/lib/indiclientd.lib) 653else() 654 # Linux or OSX 655 656 if(USE_SYSTEM_LIBINDI) 657 message(STATUS "Using system's libindi") 658 # INDI 659 # some features for indi >= 0.9 are used apparently 660 find_package(INDI 0.9 REQUIRED) 661 # source files include <libindi/baseclient.h> so we need the libindi parent directory in the include directories 662 get_filename_component(INDI_INCLUDE_PARENT_DIR ${INDI_INCLUDE_DIR} DIRECTORY) 663 include_directories(${INDI_INCLUDE_PARENT_DIR} ${INDI_INCLUDE_DIR}) 664 if(INDI_VERSION VERSION_LESS "1.4") 665 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${INDI_CLIENT_LIBRARIES} ${INDI_LIBRARIES}) 666 else(INDI_VERSION VERSION_LESS "1.4") 667 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${INDI_CLIENT_LIBRARIES}) 668 endif(INDI_VERSION VERSION_LESS "1.4") 669 if(INDI_VERSION VERSION_LESS "1.1") 670 add_definitions("-DINDI_PRE_1_1_0") 671 endif() 672 if(INDI_VERSION VERSION_LESS "1.0") 673 add_definitions("-DINDI_PRE_1_0_0") 674 endif() 675 676 # INDI depends on libz 677 find_package(ZLIB REQUIRED) 678 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${ZLIB_LIBRARIES}) 679 else() 680 681 if(APPLE) 682 # make sure to pick up the macos libz, not the mapcports libz in /opt/local/lib 683 find_library(ZLIB_LIBRARIES 684 NAMES z 685 PATHS /usr/lib 686 NO_DEFAULT_PATH) 687 if(NOT ZLIB_LIBRARIES) 688 message(FATAL_ERROR "libz not found") 689 endif() 690 else() 691 find_package(ZLIB REQUIRED) 692 endif() 693 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${ZLIB_LIBRARIES}) 694 695 # to recreate a package of libindi: 696 # cd /tmp 697 # git clone https://github.com/indilib/indi.git 698 # cd indi 699 # git archive --format=tar.gz --prefix=libindi/ --output=libindi-`git rev-parse HEAD`.tar.gz HEAD 700 701 set(indi_zip ${thirdparty_dir}/libindi-58b26c584049e1b9ecd55aa5f4a225677a417898.tar.gz) 702 message(STATUS "Using project provided libindi '${indi_zip}'") 703 set(libindi_root "${thirdparties_deflate_directory}/libindi") 704 705 # this does not work because of the configure_file commands below 706 # that want to run at camke time, but this woudl extract the 707 # libindi files at build time 708# add_custom_target(unzip_indi ALL) 709# add_custom_command(TARGET unzip_indi PRE_BUILD 710# COMMAND ${CMAKE_COMMAND} -E remove_directory ${libindi_root} 711# COMMAND ${CMAKE_COMMAND} -E tar xvf ${indi_zip} 712# WORKING_DIRECTORY ${thirdparties_deflate_directory} 713# DEPENDS ${indi_zip} 714# COMMENT "Unpacking INDI Client sources" 715# VERBATIM) 716 if(NOT EXISTS ${libindi_root}) 717 message(STATUS "[thirdparty] extracting libindi sources") 718 execute_process( 719 COMMAND ${CMAKE_COMMAND} -E tar xzf ${indi_zip} 720 WORKING_DIRECTORY ${thirdparties_deflate_directory}) 721 endif() 722 723 if(NOT APPLE) 724 # todo: OSX build fails when Nova is found. I think it needs the include dir 725 # punting for now to get the build un-broken 726 727 # Nova is required for sidereal time computation with Indi driver that not report it. 728 # This is not critical if it is not present but the hour angle computation will be wrong. 729 find_package(Nova) 730 if(NOVA_FOUND) 731 add_definitions("-DLIBNOVA") 732 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${NOVA_LIBRARIES}) 733 endif() 734 endif() 735 736 # warning: copied from the indi CMakeLists.txt. This should be updated when 737 # updating the archive of libindi 738 # those variables should be defined before the configure_files 739 set(INDI_SOVERSION "1") 740 set(CMAKE_INDI_VERSION_MAJOR 1) 741 set(CMAKE_INDI_VERSION_MINOR 5) 742 set(CMAKE_INDI_VERSION_RELEASE 0) 743 set(CMAKE_INDI_VERSION_STRING "${CMAKE_INDI_VERSION_MAJOR}.${CMAKE_INDI_VERSION_MINOR}.${CMAKE_INDI_VERSION_RELEASE}") 744 set(INDI_VERSION ${CMAKE_INDI_VERSION_MAJOR}.${CMAKE_INDI_VERSION_MINOR}.${CMAKE_INDI_VERSION_RELEASE}) 745 746 ######################################## Paths ################################################### 747 748 set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/indi/") 749 750 set(LIBINDI_DIRECTORY "${libindi_root}/libindi") 751 752 # separate folder for the configurations 753 set(libindi_root_config "${thirdparties_deflate_directory}/libindi_configuration") 754 if(NOT EXISTS ${libindi_root_config}) 755 file(MAKE_DIRECTORY "${libindi_root_config}") 756 endif() 757 758 configure_file(${LIBINDI_DIRECTORY}/config.h.cmake ${libindi_root_config}/config.h ) 759 configure_file(${LIBINDI_DIRECTORY}/indiversion.h.cmake ${libindi_root_config}/indiversion.h ) 760 761 # here we simulate the fact that the installation layout is not the same 762 # as the source layout in libindi for the client. The installation layout 763 # is needed by program 764 # we do not want to perform a full installation in a fake directory 765 # install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/baseclient.h DESTINATION ${INCLUDE_INSTALL_DIR}/libindi COMPONENT Devel) 766 if(NOT EXISTS "${libindi_root_config}/libindi") 767 file(MAKE_DIRECTORY "${libindi_root_config}/libindi") 768 endif() 769 configure_file( 770 "${LIBINDI_DIRECTORY}/libs/indibase/baseclient.h" 771 "${libindi_root_config}/libindi/baseclient.h" 772 COPYONLY) 773 set(indiclient_INC 774 indiapi.h 775 indidevapi.h 776 base64.h 777 libs/lilxml.h 778 libs/indicom.h 779 eventloop.h 780 indidriver.h 781 libs/indibase/indibase.h 782 libs/indibase/indibasetypes.h 783 libs/indibase/basedevice.h 784 libs/indibase/defaultdevice.h 785 libs/indibase/indiccd.h 786 libs/indibase/indidetector.h 787 libs/indibase/indifilterwheel.h 788 libs/indibase/indifocuserinterface.h 789 libs/indibase/indifocuser.h 790 libs/indibase/inditelescope.h 791 libs/indibase/indiguiderinterface.h 792 libs/indibase/indifilterinterface.h 793 libs/indibase/indiproperty.h 794 libs/indibase/indistandardproperty.h 795 libs/indibase/indidome.h 796 libs/indibase/indigps.h 797 libs/indibase/indilightboxinterface.h 798 libs/indibase/indidustcapinterface.h 799 libs/indibase/indiweather.h 800 libs/indibase/indilogger.h 801 libs/indibase/indicontroller.h 802 libs/indibase/indiusbdevice.h 803 libs/indibase/hidapi.h 804 805 libs/indibase/connectionplugins/connectioninterface.h 806 libs/indibase/connectionplugins/connectionserial.h 807 libs/indibase/connectionplugins/connectiontcp.h 808 ) 809 810 foreach(_file IN LISTS indiclient_INC) 811 get_filename_component(_file_wo_d "${_file}" NAME) 812 configure_file( 813 "${LIBINDI_DIRECTORY}/${_file}" 814 "${libindi_root_config}/libindi/${_file_wo_d}" 815 COPYONLY) 816 endforeach() 817 818 819 820 # include_directories( ${CMAKE_CURRENT_BINARY_DIR}) 821 ####include_directories( ${LIBINDI_DIRECTORY}) 822 ####include_directories( ${LIBINDI_DIRECTORY}/libs) 823 ####include_directories( ${LIBINDI_DIRECTORY}/libs/indibase) 824 ####include_directories( ${ZLIB_INCLUDE_DIR}) 825 ####include_directories( ${CFITSIO_INCLUDE_DIR}) 826 827 # default for libindi client 828 option(INDI_FAST_BLOB "Build INDI with Fast BLOB support" ON) 829 830 set(indiclient_C_SRC 831 ${LIBINDI_DIRECTORY}/libs/lilxml.c 832 ${LIBINDI_DIRECTORY}/base64.c 833 ${LIBINDI_DIRECTORY}/libs/indicom.c) 834 835 set(indiclient_CXX_SRC 836 ${LIBINDI_DIRECTORY}/libs/indibase/basedevice.cpp 837 ${LIBINDI_DIRECTORY}/libs/indibase/baseclient.cpp 838 ${LIBINDI_DIRECTORY}/libs/indibase/indiproperty.cpp 839 ${LIBINDI_DIRECTORY}/libs/indibase/indistandardproperty.cpp) 840 841 add_library(indiclient STATIC ${indiclient_C_SRC} ${indiclient_CXX_SRC}) 842 target_include_directories(indiclient 843 PUBLIC 844 ${libindi_root_config} 845 ${LIBINDI_DIRECTORY} 846 ${LIBINDI_DIRECTORY}/libs 847 ${LIBINDI_DIRECTORY}/libs/indibase 848 ${ZLIB_INCLUDE_DIR} 849 ${CFITSIO_INCLUDE_DIR} 850 ) 851 if(INDI_FAST_BLOB) 852 # Append ENCLEN attribute to outgoing BLOB elements to enable fast parsing by clients 853 target_compile_definitions(indiclient 854 PUBLIC 855 -DWITH_ENCLEN) 856 endif() 857 set_property(TARGET indiclient PROPERTY C_STANDARD 99) # some C code of the client requires this 858 target_link_libraries(indiclient 859 PUBLIC 860 ${CMAKE_THREAD_LIBS_INIT} 861 ${ZLIB_LIBRARIES}) # for conserving DSO 862 set_property(TARGET indiclient PROPERTY FOLDER "Thirdparty/") 863 864 # Raffi: I do not think we need this, see documentaiton for 865 # POSITION_INDEPENDENT_CODE property of CMake 866 #if (NOT CYGWIN AND NOT WIN32) 867 # set_target_properties(indiclient PROPERTIES COMPILE_FLAGS "-fPIC") 868 #endif (NOT CYGWIN AND NOT WIN32) 869 870 #install(TARGETS indiclient ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 871 #install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/libs/indibase/baseclient.h DESTINATION ${INCLUDE_INSTALL_DIR}/libindi COMPONENT Devel) 872 873 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} indiclient) 874 endif() 875 876endif() 877 878 879 880############################################# 881# 882# Windows specific dependencies 883# - Visual Leak Detector (optional) 884# - OpenCV 885# - Video For Windows (vfw) 886# - ASCOM camera stuff 887############################################# 888 889if(WIN32) 890 891 if(NOT DISABLE_VLD) 892 find_path(VLD_INCLUDE vld.h 893 HINTS "C:/Program Files (x86)/Visual Leak Detector" ENV VLD_DIR 894 PATH_SUFFIXES include 895 ) 896 if (VLD_INCLUDE) 897 get_filename_component(VLD_ROOT ${VLD_INCLUDE} DIRECTORY) 898 add_definitions(-DHAVE_VLD=1) 899 message(STATUS "Enabling VLD (${VLD_ROOT})") 900 else() 901 message(STATUS "Disabling VLD: VLD not found") 902 endif() 903 else() 904 message(STATUS "Disabling VLD: DISABLE_VLD is set") 905 endif() 906 907 # openCV 908 # openCV should be installed somewhere defined on the command line. If this is not the case, an error message is printed and 909 # the build is aborted. 910 if(NOT OpenCVRoot) 911 message(FATAL_ERROR "OpenCVRoot is not defined. OpenCVRoot should be defined with the option -DOpenCVRoot=<root-to-opencv>") 912 endif() 913 914 set(opencv_root ${OpenCVRoot}) 915 916 if(NOT EXISTS ${opencv_root}/build/include) 917 message(FATAL_ERROR "Cannot find the header directory of open cv. Please ensure you have decompressed the version for windows") 918 endif() 919 920 if(NOT EXISTS ${opencv_root}/build/OpenCVConfig.cmake) 921 message(FATAL_ERROR "Cannot find the header directory of open cvOpenCVConfig.cmake. Please ensure you have decompressed the version for windows") 922 endif() 923 924 # apparently this is the way cmake works... did not know, the OpenCVConfig.cmake file is enough for the configuration 925 set(OpenCV_DIR ${opencv_root}/build CACHE PATH "Location of the OpenCV configuration directory") 926 set(OpenCV_SHARED ON) 927 set(OpenCV_STATIC OFF) 928 set(BUILD_SHARED_LIBS ON) 929 find_package(OpenCV REQUIRED) 930 931 if(NOT OpenCV_INCLUDE_DIRS) 932 message(FATAL_ERROR "Cannot add the OpenCV include directories") 933 endif() 934 935 list(REMOVE_DUPLICATES OpenCV_LIB_DIR) 936 list(LENGTH OpenCV_LIB_DIR list_lenght) 937 if(${list_lenght} GREATER 1) 938 list(GET OpenCV_LIB_DIR 0 OpenCV_LIB_DIR) 939 endif() 940 set(OpenCV_BIN_DIR ${OpenCV_LIB_DIR}/../bin) 941 get_filename_component(OpenCV_BIN_DIR ${OpenCV_BIN_DIR} ABSOLUTE) 942 943 include_directories(${OpenCV_INCLUDE_DIRS}) 944 set(OPENCV_VER "2410") 945 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${OpenCV_LIBS}) # Raffi: maybe reduce a bit the number of libraries to link against 946 set(PHD_COPY_EXTERNAL_DBG ${PHD_COPY_EXTERNAL_DBG} ${OpenCV_BIN_DIR}/opencv_imgproc${OPENCV_VER}d.dll) 947 set(PHD_COPY_EXTERNAL_REL ${PHD_COPY_EXTERNAL_REL} ${OpenCV_BIN_DIR}/opencv_imgproc${OPENCV_VER}.dll) 948 949 set(PHD_COPY_EXTERNAL_DBG ${PHD_COPY_EXTERNAL_DBG} ${OpenCV_BIN_DIR}/opencv_highgui${OPENCV_VER}d.dll) 950 set(PHD_COPY_EXTERNAL_REL ${PHD_COPY_EXTERNAL_REL} ${OpenCV_BIN_DIR}/opencv_highgui${OPENCV_VER}.dll) 951 952 set(PHD_COPY_EXTERNAL_DBG ${PHD_COPY_EXTERNAL_DBG} ${OpenCV_BIN_DIR}/opencv_core${OPENCV_VER}d.dll) 953 set(PHD_COPY_EXTERNAL_REL ${PHD_COPY_EXTERNAL_REL} ${OpenCV_BIN_DIR}/opencv_core${OPENCV_VER}.dll) 954endif() 955 956 957# Various camera libraries 958if(WIN32) 959 # Video for Windows, directshow and windows media 960 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} vfw32.lib Strmiids.lib Quartz.lib winmm.lib) 961 962 # gpusb 963 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/ShoestringGPUSB_DLL.lib) 964 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/ShoestringGPUSB_DLL.dll) 965 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/ShoestringLXUSB_DLL.lib) 966 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/ShoestringLXUSB_DLL.dll) 967 968 # ASI cameras 969 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/ASICamera2.lib) 970 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/ASICamera2.dll) 971 972 # ToupTek cameras 973 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/toupcam.lib) 974 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/toupcam.dll) 975 976 # QHY cameras 977 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/qhyccd.lib) 978 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/qhyccd.dll) 979 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/tbb.dll) 980 981 # altair cameras 982 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/AltairCam.dll) 983 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/AltairCam_legacy.dll) 984 985 # DsiDevice 986 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/DsiDevice.lib) 987 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/DSCI.dll) 988 989 # SBIGUDrv 990 add_definitions(-DHAVE_SBIG_CAMERA=1) 991 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/SBIGUDrv.lib) 992 #set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/SBIGUDrv.dll) # this is delay load, the dll does not exist in the sources 993 994 # DICAMSDK 995 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/DICAMSDK.lib) 996 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/DICAMSDK.dll) 997 998 # SSAGIF 999 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/SSAGIF.lib) 1000 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/SSAGIFv2.dll) 1001 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/SSAGIFv4.dll) 1002 1003 # FCLib 1004 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/FCLib.lib) 1005 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/FcApi.lib) 1006 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/FCAPI.dll) 1007 1008 # SXUSB 1009 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/SXUSB.lib) 1010 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/SXUSB.dll) 1011 1012 # astroDLL 1013 #set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/astroDLLQHY5V.lib) 1014 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/astroDLLGeneric.dll) 1015 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/astroDLLQHY5V.dll) 1016 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/astroDLLsspiag.dll) 1017 1018 # CMOSDLL 1019 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/CMOSDLL.lib) 1020 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/CMOSDLL.dll) 1021 1022 # inpout32 ? 1023 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/inpout32.lib) 1024 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/inpout32.dll) 1025 1026 # some other that are explicitly loaded at runtime 1027 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/SSPIAGCAM.dll) 1028 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/SSPIAGUSB_WIN.dll) 1029 1030 # SVB cameras 1031 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/SVBCameraSDK.lib) 1032 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/WinLibs/SVBCameraSDK.dll) 1033 1034 # Moravian gX-driver cameras 1035# set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/moravian/win/lib/gXeth.lib) 1036 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${PHD_PROJECT_ROOT_DIR}/cameras/moravian/win/lib/gXusb.lib) 1037# set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/cameras/moravian/win/lib/gXeth.dll) 1038 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${PHD_PROJECT_ROOT_DIR}/cameras/moravian/win/lib/gXusb.dll) 1039 include_directories(${PHD_PROJECT_ROOT_DIR}/cameras/moravian/include) 1040 1041 set(PHD_COPY_EXTERNAL_ALL ${PHD_COPY_EXTERNAL_ALL} ${libcurl_dir}/lib/LIBCURL.DLL) 1042 1043 # ASCOM 1044 # disabled since not used in the SLN 1045 #find_package(ASCOM_INTERFACE REQUIRED) 1046 #include_directories(${ASCOM_INTERFACE_DIR}) 1047 1048endif() 1049 1050 1051############################################# 1052# SBIG specific dependencies if installed part of system 1053############################################# 1054if(SBIG_SYSTEM AND UNIX) 1055 1056 # Assumes SBIG's Universal driver has been loaded into the system and placed 1057 # in a standard path. (e.g. sbigudrv.h in /usr/include, libsbigudrv.so in /usr/lib ) 1058 # 1059 # SDK for linux can be found here -> ftp://ftp.diffractionlimited.com/pub/devsw/LinuxDevKit.tar.gz 1060 # 1061 # To rebuild libSBIG 1062 # cd ${WORKDIR}/LinuxDevKit/x86/c/testapp 1063 # local sharedlink="-shared -Wl,-soname,libSBIG-1.33.0" 1064 # g++ -c ${CXXFLAGS} -c -fPIC -I /usr/include/libusb-1.0 -I ${WORKDIR}/LinuxDevKit/x86/c/testapp csbigimg.cpp csbigcam.cpp 1065 # g++ -L ${WORKDIR}/LinuxDevKit/x86/c/lib64/ ${sharedlink} -o libSBIG=1.33.0 csbigimg.o csbigcam.o -lm -lsbigudrv -lusb -lcfitsio 1066 # ar -cvq libSBIG.a csbigimg.o csbigcam.o 1067 1068 add_definitions(-DHAVE_SBIG_CAMERA=1) 1069 add_definitions("-DTARGET=7") 1070 message(STATUS "Finding SBIG Univeral Drivers on system") 1071 find_path(SBIG_INCLUDE_DIR sbigudrv.h) 1072 find_library(SBIG_LIBRARIES NAMES SBIG) 1073 find_library(SBIGUDRV_LIBRARIES NAMES sbigudrv) 1074 include_directories(${SBIG_INCLUDE_DIR}) 1075 1076 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} SBIG sbigudrv) 1077 1078endif() 1079 1080############################################# 1081# 1082# OSX specific dependencies 1083# 1084############################################# 1085if(APPLE) 1086 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${QuickTime} ${IOKit} ${Carbon} ${Cocoa} ${System} ${Webkit} ${AudioToolbox} ${OpenGL}) 1087 1088 find_path(CARBON_INCLUDE_DIR Carbon.h) 1089 1090 1091 ############################################# 1092 # Camera frameworks 1093 # 1094 find_library( sbigudFramework 1095 NAMES SBIGUDrv 1096 PATHS ${thirdparty_dir}/frameworks) 1097 add_definitions(-DHAVE_SBIG_CAMERA=1) 1098 if(NOT sbigudFramework) 1099 message(FATAL_ERROR "Cannot find the SBIGUDrv drivers") 1100 endif() 1101 include_directories(${sbigudFramework}) 1102 add_definitions(-DHAVE_SBIG_CAMERA=1) 1103 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${sbigudFramework}) 1104 set(phd2_OSX_FRAMEWORKS ${phd2_OSX_FRAMEWORKS} ${sbigudFramework}) 1105 1106 if(APPLE32) 1107 find_library( fcCamFramework 1108 NAMES fcCamFw 1109 PATHS ${thirdparty_dir}/frameworks) 1110 if(NOT fcCamFramework) 1111 message(FATAL_ERROR "Cannot find the fcCamFw drivers") 1112 endif() 1113 include_directories(${fcCamFramework}) 1114 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${fcCamFramework}) 1115 add_definitions(-DHAVE_STARFISH_CAMERA=1) 1116 set(phd2_OSX_FRAMEWORKS ${phd2_OSX_FRAMEWORKS} ${fcCamFramework}) 1117 endif() 1118 1119 if(APPLE32) 1120 find_library( dsiMeadeLibrary 1121 NAMES DsiDevice 1122 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras) 1123 if(NOT dsiMeadeLibrary) 1124 message(FATAL_ERROR "Cannot find the dsiMeadeLibrary drivers") 1125 endif() 1126 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${dsiMeadeLibrary}) 1127 add_definitions(-DHAVE_MEADE_DSI_CAMERA=1) 1128 endif() 1129 1130 find_library( asiCamera2 1131 NAMES ASICamera2 1132 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras/zwolibs/mac) 1133 if(NOT asiCamera2) 1134 message(FATAL_ERROR "Cannot find the asiCamera2 drivers") 1135 endif() 1136 add_definitions(-DHAVE_ZWO_CAMERA=1) 1137 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${asiCamera2}) 1138 set(phd2_OSX_FRAMEWORKS ${phd2_OSX_FRAMEWORKS} ${asiCamera2}) 1139 1140 if(APPLE32) 1141 find_library( qhylib 1142 NAMES qhyccd 1143 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras/qhyccdlibs/mac/x86_32) 1144 else() 1145 find_library( qhylib 1146 NAMES qhyccd 1147 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras/qhyccdlibs/mac/x86_64) 1148 endif() 1149 if(NOT qhylib) 1150 message(FATAL_ERROR "Cannot find the qhy SDK libs") 1151 endif() 1152 add_definitions(-DHAVE_QHY_CAMERA=1) 1153 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${qhylib}) 1154 set(phd2_OSX_FRAMEWORKS ${phd2_OSX_FRAMEWORKS} ${qhylib}) 1155 1156 if(APPLE32) 1157 find_library( mallincamFramework 1158 NAMES MallincamGuider 1159 PATHS ${thirdparty_dir}/frameworks) 1160 if(NOT mallincamFramework) 1161 message(FATAL_ERROR "Cannot find the Mallincam framework") 1162 endif() 1163 include_directories(${mallincamFramework}) 1164 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${mallincamFramework}) 1165 add_definitions(-DHAVE_SKYRAIDER_CAMERA=1) 1166 set(phd2_OSX_FRAMEWORKS ${phd2_OSX_FRAMEWORKS} ${mallincamFramework}) 1167 endif() 1168 1169 if(NOT APPLE32) 1170 find_library( toupcam 1171 NAMES toupcam 1172 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras/toupcam/mac) 1173 if(NOT toupcam) 1174 message(FATAL_ERROR "Cannot find the toupcam drivers") 1175 endif() 1176 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${toupcam}) 1177 add_definitions(-DHAVE_TOUPTEK_CAMERA=1) 1178 set(phd2_OSX_FRAMEWORKS ${phd2_OSX_FRAMEWORKS} ${toupcam}) 1179 endif() 1180 1181# libDC does not seem to be used by anything, disabling it (2019/11/20 - remove in next release) 1182if(0) 1183 ############################################# 1184 # libDC 1185 # 1186 1187 set(LIBDC libdc1394-2.2.2) 1188 set(libdc_root ${thirdparties_deflate_directory}/${LIBDC}) 1189 if(NOT EXISTS ${libdc_root}) 1190 # untar the dependency 1191 execute_process( 1192 COMMAND ${CMAKE_COMMAND} -E tar xzf ${thirdparty_dir}/${LIBDC}.tar.gz 1193 WORKING_DIRECTORY ${thirdparties_deflate_directory}) 1194 endif() 1195 1196 1197 set(libdc_include_dir ${libdc_root}) 1198 set(libdc_dir ${libdc_include_dir}/dc1394) 1199 include_directories(${libdc_dir}) 1200 include_directories(${libdc_include_dir}) 1201 1202 set(libDC_SRC 1203 ${libdc_dir}/dc1394.h 1204 1205 ${libdc_dir}/bayer.c 1206 ${libdc_dir}/camera.h 1207 1208 ${libdc_dir}/capture.c 1209 ${libdc_dir}/capture.h 1210 1211 ${libdc_dir}/control.c 1212 ${libdc_dir}/control.h 1213 1214 ${libdc_dir}/conversions.c 1215 ${libdc_dir}/conversions.h 1216 1217 ${libdc_dir}/enumeration.c 1218 1219 ${libdc_dir}/format7.c 1220 ${libdc_dir}/format7.h 1221 1222 ${libdc_dir}/internal.c 1223 ${libdc_dir}/internal.h 1224 1225 ${libdc_dir}/iso.c 1226 ${libdc_dir}/iso.h 1227 1228 ${libdc_dir}/log.c 1229 ${libdc_dir}/log.h 1230 1231 ${libdc_dir}/offsets.h 1232 ${libdc_dir}/platform.h 1233 1234 ${libdc_dir}/register.c 1235 ${libdc_dir}/register.h 1236 ${libdc_dir}/types.h 1237 1238 ${libdc_dir}/utils.c 1239 ${libdc_dir}/utils.h 1240 1241 ${libdc_dir}/video.h 1242 1243 # USB backend 1244 ${libdc_dir}/usb/capture.c 1245 ${libdc_dir}/usb/control.c 1246 ${libdc_dir}/usb/usb.h 1247 1248 # mac specific 1249 ${libdc_dir}/macosx.c 1250 ${libdc_dir}/macosx.h 1251 ${libdc_dir}/macosx/control.c 1252 ${libdc_dir}/macosx/capture.c 1253 ${libdc_dir}/macosx/macosx.h 1254 1255 ) 1256 1257 add_library(dc ${libDC_SRC}) 1258 target_include_directories(dc PRIVATE ${thirdparty_dir}/include/${LIBDC}) 1259 set_property(TARGET dc PROPERTY FOLDER "Thirdparty/") 1260 # the following line generated too many warnings. The macros are already defined in the config.h of this library 1261 # target_compile_definitions(dc PRIVATE HAVE_LIBUSB HAVE_MACOSX) 1262 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} dc) 1263endif() 1264 1265 1266 1267 1268 ############################################# 1269 # HID Utils 1270 # 1271 #if(NOT EXISTS "${thirdparty_dir}/HID Utilities Source") 1272 # # untar the dependency 1273 # execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf "${thirdparty_dir}/HID Utilities Source.zip") 1274 #endif() 1275 1276 # library removed 1277 1278 1279 ### does not work on x64 1280 #find_library( openssag 1281 # NAMES openssag 1282 # PATHS ${PHD_PROJECT_ROOT_DIR}/cameras ) 1283 #if(NOT openssag) 1284 # message(FATAL_ERROR "Cannot find the openssag drivers") 1285 #endif() 1286 #set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${openssag}) 1287 1288 set(LIBOPENSSAG openssag) 1289 set(libopenssag_dir ${thirdparty_dir}/${LIBOPENSSAG}/src) 1290 include_directories(${libopenssag_dir}) 1291 set(libOPENSSAG_SRC 1292 ${libopenssag_dir}/firmware.h 1293 ${libopenssag_dir}/loader.cpp 1294 ${libopenssag_dir}/openssag_priv.h 1295 ${libopenssag_dir}/openssag.cpp 1296 ${libopenssag_dir}/openssag.h 1297 ) 1298 add_library(OpenSSAG ${libOPENSSAG_SRC}) 1299 target_include_directories(OpenSSAG PRIVATE ${thirdparty_dir}/${LIBOPENSSAG}/src) 1300 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} OpenSSAG) 1301 add_definitions(-DHAVE_OPENSSAG_CAMERA=1) 1302 set_property(TARGET OpenSSAG PROPERTY FOLDER "Thirdparty/") 1303 1304endif() # APPLE 1305 1306 1307 1308 1309 1310 1311############################################# 1312# 1313# Unix/Linux specific dependencies 1314# - ASI cameras 1315# - USB (commonly shared) 1316# - math (libm) 1317# - 1318# 1319############################################# 1320if(UNIX AND NOT APPLE) 1321 1322 if (NOT OPENSOURCE_ONLY) 1323 1324 if (CMAKE_SYSTEM_PROCESSOR MATCHES "^armv6(.*)") 1325 set(zwoarch "armv6") 1326 set(qhyarch "armv6") 1327 set(toupcam_arch "armel") 1328 elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^armv7(.*)|arm64|aarch64|^armv8(.*)") 1329 if(CMAKE_SIZEOF_VOID_P EQUAL 8) 1330 set(zwoarch "armv8") 1331 set(qhyarch "armv8") 1332 set(toupcam_arch "arm64") 1333 else() 1334 set(zwoarch "armv7") 1335 set(qhyarch "armv7") 1336 set(toupcam_arch "armhf") 1337 endif() 1338 elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86|X86|amd64|AMD64|i.86") 1339 if(CMAKE_SIZEOF_VOID_P EQUAL 8) 1340 set(zwoarch "x64") 1341 set(qhyarch "x86_64") 1342 set(toupcam_arch "x64") 1343 else() 1344 set(zwoarch "x86") 1345 set(qhyarch "x86_32") 1346 set(toupcam_arch "x86") 1347 endif() 1348 else() 1349 message(FATAL_ERROR "unknown system architecture") 1350 endif() 1351 1352 find_path(ZWO_INCLUDE_DIR ASICamera2.h 1353 NO_DEFAULT_PATHS 1354 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras 1355 ) 1356 1357 # The binary libraries below do not support FreeBSD, ignore them 1358 # when building for FreeBSD. 1359 if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") 1360 find_library(asiCamera2 1361 NAMES ASICamera2 1362 NO_DEFAULT_PATHS 1363 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras/zwolibs/${zwoarch}) 1364 1365 if(NOT asiCamera2) 1366 message(FATAL_ERROR "Cannot find the asiCamera2 drivers") 1367 endif() 1368 message(STATUS "Found ASICamera2 lib ${asiCamera2}") 1369 add_definitions(-DHAVE_ZWO_CAMERA=1) 1370 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${asiCamera2}) 1371 1372 find_library(toupcam 1373 NAMES toupcam 1374 NO_DEFAULT_PATHS 1375 NO_CMAKE_SYSTEM_PATH 1376 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras/toupcam/linux/${toupcam_arch}) 1377 if(NOT toupcam) 1378 message(FATAL_ERROR "Cannot find the toupcam drivers") 1379 endif() 1380 message(STATUS "Found toupcam lib ${toupcam}") 1381 add_definitions(-DHAVE_TOUPTEK_CAMERA=1) 1382 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${toupcam}) 1383 set(PHD_INSTALL_LIBS ${PHD_INSTALL_LIBS} ${toupcam}) 1384 1385 if(IS_DIRECTORY ${PHD_PROJECT_ROOT_DIR}/cameras/qhyccdlibs/linux/${qhyarch}) 1386 add_definitions(-DHAVE_QHY_CAMERA=1) 1387 1388 # be careful not to pick up any other qhy lib on the system 1389 find_library(qhylib 1390 NAMES qhyccd 1391 NO_DEFAULT_PATH 1392 PATHS ${PHD_PROJECT_ROOT_DIR}/cameras/qhyccdlibs/linux/${qhyarch}) 1393 if(NOT qhylib) 1394 message(FATAL_ERROR "Cannot find the qhy SDK libs") 1395 endif() 1396 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${qhylib}) 1397 endif() 1398 endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") 1399 1400 find_program(LSB_RELEASE_EXEC lsb_release) 1401 if(LSB_RELEASE_EXEC) 1402 execute_process(COMMAND ${LSB_RELEASE_EXEC} -is 1403 OUTPUT_VARIABLE LSB_RELEASE_ID 1404 OUTPUT_STRIP_TRAILING_WHITESPACE 1405 ERROR_QUIET 1406 ) 1407 execute_process(COMMAND ${LSB_RELEASE_EXEC} -rs 1408 OUTPUT_VARIABLE LSB_RELEASE_RELEASE 1409 OUTPUT_STRIP_TRAILING_WHITESPACE 1410 ERROR_QUIET 1411 ) 1412 # temporarily disable qhy camera pending fix for link error on Ubuntu Trusty 1413 if((${LSB_RELEASE_ID} STREQUAL "Ubuntu") AND (${LSB_RELEASE_RELEASE} STREQUAL "14.04")) 1414 message(STATUS "Disabling QHY camera support on this platform") 1415 remove_definitions(-DHAVE_QHY_CAMERA=1) 1416 endif() 1417 endif() 1418 1419 set(LIBOPENSSAG openssag) 1420 set(libopenssag_dir ${thirdparty_dir}/${LIBOPENSSAG}/src) 1421 include_directories(${libopenssag_dir}) 1422 set(libOPENSSAG_SRC 1423 ${libopenssag_dir}/firmware.h 1424 ${libopenssag_dir}/loader.cpp 1425 ${libopenssag_dir}/openssag_priv.h 1426 ${libopenssag_dir}/openssag.cpp 1427 ${libopenssag_dir}/openssag.h 1428 ) 1429 add_library(OpenSSAG ${libOPENSSAG_SRC}) 1430 target_include_directories(OpenSSAG PRIVATE ${thirdparty_dir}/${LIBOPENSSAG}/src) 1431 add_definitions(-DHAVE_OPENSSAG_CAMERA=1) 1432 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} OpenSSAG) 1433 set_property(TARGET OpenSSAG PROPERTY FOLDER "Thirdparty/") 1434 1435 endif() # OPENSOURCE_ONLY 1436 1437 # math library is needed, and should be one of the last things to link to here 1438 find_library(mathlib NAMES m) 1439 set(PHD_LINK_EXTERNAL ${PHD_LINK_EXTERNAL} ${mathlib}) 1440 1441endif() 1442 1443############################################# 1444# Starlight Xpress 1445############################################# 1446 1447if(WIN32) 1448 add_definitions(-DHAVE_SXV_CAMERA=1) 1449elseif(UNIX OR APPLE) 1450 add_definitions(-DHAVE_SXV_CAMERA=1) 1451 set(SXV_PLATFORM_SRC 1452 ${phd_src_dir}/cameras/SXMacLib.h 1453 ${phd_src_dir}/cameras/SXMacLib.c) 1454endif() 1455 1456 1457############################################# 1458# KwiqGuider 1459############################################# 1460 1461if(APPLE) 1462 add_definitions(-DHAVE_KWIQGUIDER_CAMERA=1) 1463 include_directories(${phd_src_dir}/cam_KWIQGuider/) 1464 set(KWIQGuider_PLATFORM_SRC 1465 ${phd_src_dir}/cam_KWIQGuider/KWIQGuider.cpp 1466 ${phd_src_dir}/cam_KWIQGuider/KWIQGuider.h 1467 ${phd_src_dir}/cam_KWIQGuider/KWIQGuider_firmware.h 1468 ${phd_src_dir}/cam_KWIQGuider/KWIQGuider_loader.cpp 1469 ${phd_src_dir}/cam_KWIQGuider/KWIQGuider_priv.h 1470 ) 1471endif() 1472 1473 1474############################################# 1475# 1476# gettext and msgmerge tools for documentation/internationalization 1477# 1478############################################# 1479 1480# zip file support integrated in cmake 3.2+ 1481if(WIN32 AND ("${CMAKE_VERSION}" VERSION_GREATER "3.2") 1482 AND ("${GETTEXT_ROOT}" STREQUAL "")) 1483 1484 # GETTEXT_ROOT not given from the command line: deflating our own 1485 1486 set(GETTEXTTOOLS gettext-0.14.4) 1487 set(GETTEXT_ROOT ${thirdparties_deflate_directory}/${GETTEXTTOOLS}) 1488 1489 # deflate 1490 if(NOT EXISTS ${GETTEXT_ROOT}) 1491 1492 message(STATUS "Deflating gettexttools from thirdparties to ${GETTEXT_ROOT}") 1493 # create directory 1494 if(NOT EXISTS ${GETTEXT_ROOT}) 1495 file(MAKE_DIRECTORY ${GETTEXT_ROOT}) 1496 endif() 1497 1498 # untar the dependency 1499 execute_process( 1500 COMMAND ${CMAKE_COMMAND} -E tar xzf ${thirdparty_dir}/${GETTEXTTOOLS}-bin.zip 1501 WORKING_DIRECTORY ${GETTEXT_ROOT}) 1502 execute_process( 1503 COMMAND ${CMAKE_COMMAND} -E tar xzf ${thirdparty_dir}/${GETTEXTTOOLS}-dep.zip 1504 WORKING_DIRECTORY ${GETTEXT_ROOT}) 1505 endif() 1506 1507endif() 1508 1509set(GETTEXT_FINDPROGRAM_OPTIONS) 1510if(NOT ("${GETTEXT_ROOT}" STREQUAL "")) 1511 set(GETTEXT_FINDPROGRAM_OPTIONS 1512 PATHS ${GETTEXT_ROOT} 1513 PATH_SUFFIXES bin 1514 DOC "gettext program deflated from the thirdparties" 1515 NO_DEFAULT_PATH) 1516endif() 1517 1518find_program(XGETTEXT 1519 NAMES xgettext 1520 ${GETTEXT_FINDPROGRAM_OPTIONS}) 1521 1522find_program(MSGFMT 1523 NAMES msgfmt 1524 ${GETTEXT_FINDPROGRAM_OPTIONS}) 1525 1526find_program(MSGMERGE 1527 NAMES msgmerge 1528 ${GETTEXT_FINDPROGRAM_OPTIONS}) 1529 1530if(NOT XGETTEXT) 1531 message(STATUS "'xgettext' program not found") 1532else() 1533 message(STATUS "'xgettext' program found at '${XGETTEXT}'") 1534endif() 1535 1536if(NOT MSGFMT) 1537 message(STATUS "'msgfmt' program not found") 1538else() 1539 message(STATUS "'msgfmt' program found at '${MSGFMT}'") 1540endif() 1541 1542if(NOT MSGMERGE) 1543 message(STATUS "'msgmerge' program not found") 1544else() 1545 message(STATUS "'msgmerge' program found at '${MSGMERGE}'") 1546endif() 1547