Commit 941d764c authored by Davis King's avatar Davis King

Changed cmake so that there is only the dlib target and it isn't forced

to be static or shared, instead, the build type will toggle based on the
state of CMake's BUILD_SHARED_LIBS variable.
parent f6ea3397
......@@ -195,11 +195,7 @@ if (NOT TARGET dlib)
set(dlib_needed_includes)
if (DLIB_ISO_CPP_ONLY)
add_library(dlib STATIC ${source_files} )
if (UNIX AND NOT DLIB_IN_PROJECT_BUILD)
add_library(dlib_shared SHARED ${source_files} )
add_dependencies(dlib_shared dlib)
endif()
add_library(dlib ${source_files} )
else()
set(source_files ${source_files}
......@@ -697,18 +693,9 @@ if (NOT TARGET dlib)
# The old cuda_add_library() command doesn't support CMake's newer dependency
# stuff, so we have to set the include path manually still, which we do here.
include_directories(${dlib_needed_includes})
cuda_add_library(dlib STATIC ${source_files} )
cuda_add_library(dlib ${source_files} )
else()
add_library(dlib STATIC ${source_files} )
endif()
if (UNIX AND NOT DLIB_IN_PROJECT_BUILD)
if (DLIB_USE_CUDA)
cuda_add_library(dlib_shared SHARED ${source_files} )
add_dependencies(dlib_shared dlib)
else()
add_library(dlib_shared SHARED ${source_files} )
add_dependencies(dlib_shared dlib)
endif()
add_library(dlib ${source_files} )
endif()
endif () ##### end of if NOT DLIB_ISO_CPP_ONLY ##########################################################
......@@ -719,21 +706,12 @@ if (NOT TARGET dlib)
INTERFACE $<INSTALL_INTERFACE:include>
PUBLIC ${dlib_needed_includes}
)
target_link_libraries(dlib PRIVATE ${dlib_needed_libraries})
target_link_libraries(dlib PUBLIC ${dlib_needed_libraries})
if (DLIB_IN_PROJECT_BUILD)
target_compile_options(dlib PUBLIC ${active_preprocessor_switches})
else()
target_compile_options(dlib PRIVATE ${active_preprocessor_switches})
endif()
if (UNIX AND NOT DLIB_IN_PROJECT_BUILD)
target_include_directories(dlib_shared
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
INTERFACE $<INSTALL_INTERFACE:include>
PUBLIC ${dlib_needed_includes}
)
target_link_libraries(dlib_shared PUBLIC ${dlib_needed_libraries})
target_compile_options(dlib_shared PRIVATE ${active_preprocessor_switches})
endif()
# Allow the unit tests to ask us to compile the all/source.cpp file just to make sure it compiles.
......@@ -748,29 +726,16 @@ if (NOT TARGET dlib)
enable_cpp11_for_target(dlib)
target_compile_options(dlib PUBLIC ${active_compile_opts})
endif()
if (TARGET dlib_shared)
enable_cpp11_for_target(dlib_shared)
target_compile_options(dlib_shared PUBLIC ${active_compile_opts})
endif()
# Install the library
if (NOT DLIB_IN_PROJECT_BUILD)
if(UNIX)
set_target_properties(dlib_shared PROPERTIES
OUTPUT_NAME dlib
VERSION ${VERSION})
install(TARGETS dlib dlib_shared
EXPORT dlib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Windows (including cygwin) considers .dll to be runtime artifacts
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
else()
install(TARGETS dlib
EXPORT dlib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Windows considers .dll to be runtime artifacts
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_target_properties(dlib PROPERTIES
VERSION ${VERSION})
install(TARGETS dlib
EXPORT dlib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Windows considers .dll to be runtime artifacts
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dlib
FILES_MATCHING PATTERN "*.h" PATTERN "*.cmake"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment