If we are building mlpack statically then build executable statically too

This pull request is not related to cross-compilation.

Signed-off-by: Omar Shrit <omar@shrit.me>
This commit is contained in:
Omar Shrit
2021-04-24 19:24:32 +02:00
parent 83e7011059
commit 54267705ed
2 changed files with 30 additions and 11 deletions
+15 -5
View File
@@ -50,11 +50,21 @@ if (BUILD_CLI_EXECUTABLES)
add_executable(mlpack_${name}
${name}_main.cpp
)
target_link_libraries(mlpack_${name}
mlpack
${ARMADILLO_LIBRARIES}
${COMPILER_SUPPORT_LIBRARIES}
)
# Build mlpack CLI binding binaries statically.
if(NOT BUILD_SHARED_LIBS)
target_link_libraries(mlpack_${name} -static
mlpack
${ARMADILLO_LIBRARIES}
${COMPILER_SUPPORT_LIBRARIES}
)
else()
# Build mlpack CLI binding binaries dynamically.
target_link_libraries(mlpack_${name}
mlpack
${ARMADILLO_LIBRARIES}
${COMPILER_SUPPORT_LIBRARIES}
)
endif()
# Make sure that we set BINDING_TYPE to cli so the command-line program is
# compiled with the correct int main() call.
set_target_properties(mlpack_${name} PROPERTIES COMPILE_FLAGS
+15 -6
View File
@@ -175,12 +175,21 @@ add_executable(mlpack_test
main_tests/test_helper.hpp
)
# Link dependencies of test executable.
target_link_libraries(mlpack_test
mlpack
${ARMADILLO_LIBRARIES}
${COMPILER_SUPPORT_LIBRARIES}
)
if(NOT BUILD_SHARED_LIBS)
# Build mlpack test executable statically.
target_link_libraries(mlpack_test -static
mlpack
${ARMADILLO_LIBRARIES}
${COMPILER_SUPPORT_LIBRARIES}
)
else()
# Build mlpack test executable dynamically.
target_link_libraries(mlpack_test
mlpack
${ARMADILLO_LIBRARIES}
${COMPILER_SUPPORT_LIBRARIES}
)
endif()
set_target_properties(mlpack_test PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "../core.hpp")
cotire(mlpack_test)