diff --git a/CMakeLists.txt b/CMakeLists.txt index 10efdef..bed11c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}") find_package(Threads REQUIRED) # find_package(spdlog REQUIRED) -# find_package(spdlog CONFIG) +find_package(spdlog CONFIG) find_package(CFITSIO REQUIRED) find_package(XCLIB REQUIRED) @@ -21,7 +21,8 @@ set(RAPTOR_EAGLEV_LIB raptor_eaglev) option(STATIC_LIB "Create static '${RAPTOR_EAGLEV_LIB}' library" OFF) set(RAPTOR_EAGLEV_LIB_SRC - raptor_eagle_ccd.h raptor_eagle_ccd.cpp + raptor_eagle_ccd.h + raptor_eagle_ccd.cpp raptor_eagle_cameralink.h raptor_eagle_exception.h raptor_eagle_acqproc.cpp) @@ -32,21 +33,21 @@ else() add_library(${RAPTOR_EAGLEV_LIB} SHARED ${RAPTOR_EAGLEV_LIB_SRC}) endif() -include(FetchContent) -include(ExternalProject) +# include(FetchContent) +# include(ExternalProject) -FetchContent_Declare(spdlog - # SOURCE_DIR ${CMAKE_BINARY_DIR}/spdlog - # BINARY_DIR ${CMAKE_BINARY_DIR}/spdlog/build - GIT_REPOSITORY "https://github.com/gabime/spdlog.git" - GIT_TAG "v1.15.0" - GIT_SHALLOW TRUE - GIT_SUBMODULES "" - GIT_PROGRESS TRUE -) -FetchContent_MakeAvailable(spdlog) -FetchContent_GetProperties(spdlog SOURCE_DIR spdlog_SOURCE_DIR) -set(spdlog_INCLUDE_DIR ${spdlog_SOURCE_DIR}/include) +# FetchContent_Declare(spdlog +# # SOURCE_DIR ${CMAKE_BINARY_DIR}/spdlog +# # BINARY_DIR ${CMAKE_BINARY_DIR}/spdlog/build +# GIT_REPOSITORY "https://github.com/gabime/spdlog.git" +# GIT_TAG "v1.15.0" +# GIT_SHALLOW TRUE +# GIT_SUBMODULES "" +# GIT_PROGRESS TRUE +# ) +# FetchContent_MakeAvailable(spdlog) +# FetchContent_GetProperties(spdlog SOURCE_DIR spdlog_SOURCE_DIR) +# set(spdlog_INCLUDE_DIR ${spdlog_SOURCE_DIR}/include) # to activate spdlog-library support in ADC-library @@ -57,7 +58,8 @@ target_compile_definitions(${RAPTOR_EAGLEV_LIB} PUBLIC SPDLOG_USE_STD_FORMAT) # !!!!! TEMPORARY !!!!! target_include_directories(${RAPTOR_EAGLEV_LIB} PUBLIC "../ADC/") target_include_directories(${RAPTOR_EAGLEV_LIB} PUBLIC ${XCLIB_INCLUDE_DIR} ${CFITSIO_INCLUDE_DIR}) -target_include_directories(${RAPTOR_EAGLEV_LIB} PUBLIC ${spdlog_INCLUDE_DIR}) +# target_include_directories(${RAPTOR_EAGLEV_LIB} PUBLIC ${spdlog_INCLUDE_DIR}) +target_include_directories(${RAPTOR_EAGLEV_LIB} PUBLIC spdlog::spdlog_header_only) # target_link_libraries(${RAPTOR_EAGLEV_LIB} PUBLIC Threads::Threads spdlog::spdlog_header_only ${XCLIB_LIBRARIES} ${CFITSIO_LIBRARY}) target_link_libraries(${RAPTOR_EAGLEV_LIB} PUBLIC Threads::Threads ${XCLIB_LIBRARIES} ${CFITSIO_LIBRARY}) @@ -67,12 +69,24 @@ add_executable(${RAPTOR_EAGLEV_SERVER} raptor_eaglev_server.cpp) target_link_libraries(${RAPTOR_EAGLEV_SERVER} PUBLIC ${RAPTOR_EAGLEV_LIB} cxxopts::cxxopts) include(GNUInstallDirs) -install(TARGETS ${RAPTOR_EAGLEV_LIB} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) -# install(TARGETS ${RAPTOR_EAGLEV_LIB} ${RAPTOR_EAGLEV_SERVER} -# LIBRARY DESTINATION "/home/obs/TMP" -# ARCHIVE DESTINATION "/home/obs/TMP" -# RUNTIME DESTINATION "/home/obs/TMP" -# ) +if (STATIC_LIB) # install only server binary + install(TARGETS ${RAPTOR_EAGLEV_SERVER} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) +else() + install(TARGETS ${RAPTOR_EAGLEV_LIB} ${RAPTOR_EAGLEV_SERVER} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) +endif() + +# uninstall target +if(NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif() diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 0000000..e70743a --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,19 @@ +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif() + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else() + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif() +endforeach()