diff --git a/CMakeLists.txt b/CMakeLists.txt index fe882b1..1f6bedd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,9 @@ option(BUILD_SHARED_LIBS "Build shared libraries instead of static libraries" ON option(VISP_VULKAN "Enable Vulkan support" OFF) option(VISP_DEV "Enable development mode" OFF) option(VISP_CI "Enable for continuous integration environment" OFF) +option(VISP_PACKAGE "Build for packaging and distribution" OFF) option(VISP_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL}) -option(VISP_INSTALL_MODELS "Download and install default models" OFF) +option(VISP_INSTALL_MODELS "Download and install default models" ${VISP_PACKAGE}) option(VISP_FMT_LIB "Use external fmt library instead of standard C++ " OFF) option(VISP_STATIC_GGML "Force static build of ggml" OFF) option(VISP_ASAN "Enable AddressSanitizer" OFF) @@ -25,6 +26,10 @@ if(PROJECT_IS_TOP_LEVEL) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + if (VISP_PACKAGE) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) + endif() endif() # Set default build type to Release (except for multi-config generators) @@ -76,6 +81,9 @@ elseif(UNIX AND NOT APPLE) # Disable omitting dependencies from ELF binaries so they can be found via RPATH list(APPEND VISP_LINK_OPTIONS -Wl,--no-as-needed) endif() + if(VISP_PACKAGE) + list(APPEND VISP_LINK_OPTIONS -Wl,--exclude-libs,ALL) + endif() endif() # Configure warnings diff --git a/scripts/pkg-check/check-package.sh b/scripts/pkg-check/check-package.sh index 71394c8..635815f 100644 --- a/scripts/pkg-check/check-package.sh +++ b/scripts/pkg-check/check-package.sh @@ -85,7 +85,7 @@ step1() { -D VISP_VULKAN=OFF \ -D VISP_TESTS=OFF \ -D VISP_STATIC_GGML=ON \ - -D VISP_INSTALL_MODELS=ON + -D VISP_PACKAGE=ON cmake --build "$SRC_BUILD_DIR" diff --git a/src/visp/CMakeLists.txt b/src/visp/CMakeLists.txt index c8d51aa..fc4d32b 100644 --- a/src/visp/CMakeLists.txt +++ b/src/visp/CMakeLists.txt @@ -33,6 +33,6 @@ set_target_properties(visioncpp PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} ) -if (MSVC AND VISP_TESTS) +if (MSVC AND VISP_TESTS AND NOT VISP_PACKAGE) set_target_properties(visioncpp PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 72b41a5..f31792d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -45,6 +45,10 @@ target_compile_options(vision-workbench PRIVATE ${VISP_COMP_OPTIONS}) target_link_options(vision-workbench PRIVATE ${VISP_LINK_OPTIONS}) target_link_libraries(vision-workbench PRIVATE visioncpp ggml ${VISP_FMT_LINK}) +if(VISP_PACKAGE) + message(WARNING "Some tests may not work due to symbol visibility settings for packaging. Use VISP_PACKAGE=OFF to run all tests. Use VISP_TESTS=OFF when packaging.") +endif() + # # Python tests