diff --git a/sophiread/CMakeLists.txt b/sophiread/CMakeLists.txt index a4dfb92..a6a57c3 100644 --- a/sophiread/CMakeLists.txt +++ b/sophiread/CMakeLists.txt @@ -23,8 +23,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() +include(GNUInstallDirs) + set(CMAKE_CXX_STANDARD 20) -# set(CMAKE_AUTOMOC ON) # for meta object compiler, needed for Qt5 +set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") +set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Dependencies find_package(Eigen3 REQUIRED) @@ -35,7 +39,6 @@ find_package(TBB REQUIRED) find_package(TIFF REQUIRED) find_package(spdlog 1.8.0 REQUIRED) find_package(fmt 7.0.0 REQUIRED) -# find_package(Qt5 COMPONENTS Widgets REQUIRED) # Testing setup enable_testing() @@ -54,19 +57,35 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") add_compile_options(-march=native -ffast-math -pthread -Wall -Wextra) endif() -# Add Sophiread library NOTE: this will take care of the testing as well -# add_subdirectory(SophireadLib) - # Add FastSophiread library add_subdirectory(FastSophiread) - -# Add Sophiread command line interface add_subdirectory(SophireadCLI) -# Add Sophiread stream command line interface -# add_subdirectory(SophireadStreamCLI) +# ----------------- PACKAGE CONFIGURATION ----------------- # + +# Export targets from subdirectories +install( + EXPORT sophireadTargets + FILE sophireadTargets.cmake + NAMESPACE sophiread:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sophiread) + +# Generate and install the sophireadConfig.cmake and +# sophireadConfigVersion.cmake files +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/sophireadConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sophireadConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/sophireadConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sophiread) -# Add Sophiread GUI application add_subdirectory(SophireadGUI) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sophireadConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/sophireadConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sophiread) # ----------------- DOXYGEN ----------------- # find_package(Doxygen) diff --git a/sophiread/FastSophiread/CMakeLists.txt b/sophiread/FastSophiread/CMakeLists.txt index 6205ecb..8e64f16 100644 --- a/sophiread/FastSophiread/CMakeLists.txt +++ b/sophiread/FastSophiread/CMakeLists.txt @@ -6,10 +6,25 @@ set(SRC_FAST_FILES src/abs.cpp src/centroid.cpp src/disk_io.cpp add_library(FastSophiread ${SRC_FAST_FILES}) target_include_directories( FastSophiread - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include $ENV{CONDA_PREFIX}/include + PUBLIC $ + $ $ENV{CONDA_PREFIX}/include ${EIGEN3_INCLUDE_DIR} ${HDF5_INCLUDE_DIRS}) target_link_directories(FastSophiread PRIVATE $ENV{CONDA_PREFIX}/lib) +# Install the library +install( + TARGETS FastSophiread + EXPORT sophireadTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# Install the headers +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + # ----------------- TESTS ----------------- # function(add_sophiread_test test_name) add_executable(${test_name} tests/test_${test_name}.cpp) diff --git a/sophiread/SophireadCLI/CMakeLists.txt b/sophiread/SophireadCLI/CMakeLists.txt index 149fc48..3691438 100644 --- a/sophiread/SophireadCLI/CMakeLists.txt +++ b/sophiread/SophireadCLI/CMakeLists.txt @@ -81,6 +81,17 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) "/usr/local" CACHE PATH "Default install prefix" FORCE) endif() -install(TARGETS Sophiread RUNTIME DESTINATION bin) + +# Install executables +install( + TARGETS Sophiread venus_auto_reducer + EXPORT sophireadTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# Install the headers +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# Set up packaging (optional) set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") include(CPack) diff --git a/sophiread/cmake/sophireadConfig.cmake.in b/sophiread/cmake/sophireadConfig.cmake.in new file mode 100644 index 0000000..9ec0ecd --- /dev/null +++ b/sophiread/cmake/sophireadConfig.cmake.in @@ -0,0 +1,7 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/sophireadTargets.cmake") + +# Optionally, include additional paths or variables +set(SOPHIREAD_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@") +set(SOPHIREAD_LIBRARIES sophiread::FastSophiread) diff --git a/sophiread/include/version.h b/sophiread/include/version.h index 4d9f4f1..720def3 100644 --- a/sophiread/include/version.h +++ b/sophiread/include/version.h @@ -1,6 +1,6 @@ /**version.h * - * Copyright 2023. + * Copyright 2024. */ #ifndef VERSION_H @@ -12,7 +12,7 @@ // Version number #define VERSION_MAJOR 2 -#define VERSION_MINOR 0 +#define VERSION_MINOR 3 #define VERSION_PATCH 0 // Version number final