Commit 8b5b6fb0 authored by Davis King's avatar Davis King

All I did was put an "if (NOT TARGET dlib)" around the main body of the CMakeLists.txt

so that we avoid a common cmake warning.
parent e20926e8
...@@ -41,40 +41,49 @@ if (NOT CMAKE_CXX_FLAGS_DEBUG MATCHES "-DENABLE_ASSERTS") ...@@ -41,40 +41,49 @@ if (NOT CMAKE_CXX_FLAGS_DEBUG MATCHES "-DENABLE_ASSERTS")
FORCE) FORCE)
endif () endif ()
set (DLIB_ISO_CPP_ONLY_STR
"Enable this if you don't want to compile any non-ISO C++ code (i.e. you don't use any of the API Wrappers)" ) # Don't try to call add_library(dlib) and setup dlib's stuff if it has already
set (DLIB_NO_GUI_SUPPORT_STR # been done by some other part of the current cmake project. We do this
"Enable this if you don't want to compile any of the dlib GUI code" ) # because it avoids getting warnings/errors about cmake policy CMP0002. This
set (DLIB_ENABLE_STACK_TRACE_STR # happens when a project tries to call add_subdirectory() on dlib more than
"Enable this if you want to turn on the DLIB_STACK_TRACE macros" ) # once. This most often happens when the top level of a project depends on two
set (DLIB_ENABLE_ASSERTS_STR # or more other things which both depend on dlib.
"Enable this if you want to turn on the DLIB_ASSERT macro" ) if (NOT TARGET dlib)
set (DLIB_USE_BLAS_STR
"Disable this if you don't want to use a BLAS library" ) set (DLIB_ISO_CPP_ONLY_STR
set (DLIB_USE_LAPACK_STR "Enable this if you don't want to compile any non-ISO C++ code (i.e. you don't use any of the API Wrappers)" )
"Disable this if you don't want to use a LAPACK library" ) set (DLIB_NO_GUI_SUPPORT_STR
set (DLIB_LINK_WITH_LIBPNG_STR "Enable this if you don't want to compile any of the dlib GUI code" )
"Disable this if you don't want to link against libpng" ) set (DLIB_ENABLE_STACK_TRACE_STR
set (DLIB_LINK_WITH_LIBJPEG_STR "Enable this if you want to turn on the DLIB_STACK_TRACE macros" )
"Disable this if you don't want to link against libjpeg" ) set (DLIB_ENABLE_ASSERTS_STR
set (DLIB_LINK_WITH_SQLITE3_STR "Enable this if you want to turn on the DLIB_ASSERT macro" )
"Disable this if you don't want to link against sqlite3" ) set (DLIB_USE_BLAS_STR
"Disable this if you don't want to use a BLAS library" )
option(DLIB_ISO_CPP_ONLY ${DLIB_ISO_CPP_ONLY_STR} OFF) set (DLIB_USE_LAPACK_STR
option(DLIB_NO_GUI_SUPPORT ${DLIB_NO_GUI_SUPPORT_STR} OFF) "Disable this if you don't want to use a LAPACK library" )
option(DLIB_ENABLE_STACK_TRACE ${DLIB_ENABLE_STACK_TRACE_STR} OFF) set (DLIB_LINK_WITH_LIBPNG_STR
option(DLIB_ENABLE_ASSERTS ${DLIB_ENABLE_ASSERTS_STR} OFF) "Disable this if you don't want to link against libpng" )
option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} ON) set (DLIB_LINK_WITH_LIBJPEG_STR
option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} ON) "Disable this if you don't want to link against libjpeg" )
option(DLIB_LINK_WITH_LIBPNG ${DLIB_LINK_WITH_LIBPNG_STR} ON) set (DLIB_LINK_WITH_SQLITE3_STR
option(DLIB_LINK_WITH_LIBJPEG ${DLIB_LINK_WITH_LIBJPEG_STR} ON) "Disable this if you don't want to link against sqlite3" )
option(DLIB_LINK_WITH_SQLITE3 ${DLIB_LINK_WITH_SQLITE3_STR} ON)
option(DLIB_ISO_CPP_ONLY ${DLIB_ISO_CPP_ONLY_STR} OFF)
option(DLIB_NO_GUI_SUPPORT ${DLIB_NO_GUI_SUPPORT_STR} OFF)
add_library(dlib STATIC all/source.cpp ) option(DLIB_ENABLE_STACK_TRACE ${DLIB_ENABLE_STACK_TRACE_STR} OFF)
option(DLIB_ENABLE_ASSERTS ${DLIB_ENABLE_ASSERTS_STR} OFF)
option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} ON)
if (NOT DLIB_ISO_CPP_ONLY) option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} ON)
option(DLIB_LINK_WITH_LIBPNG ${DLIB_LINK_WITH_LIBPNG_STR} ON)
option(DLIB_LINK_WITH_LIBJPEG ${DLIB_LINK_WITH_LIBJPEG_STR} ON)
option(DLIB_LINK_WITH_SQLITE3 ${DLIB_LINK_WITH_SQLITE3_STR} ON)
add_library(dlib STATIC all/source.cpp )
if (NOT DLIB_ISO_CPP_ONLY)
# we want to link to the right stuff depending on our platform. # we want to link to the right stuff depending on our platform.
if (WIN32 AND NOT CYGWIN) ############################################################################### if (WIN32 AND NOT CYGWIN) ###############################################################################
if (DLIB_NO_GUI_SUPPORT) if (DLIB_NO_GUI_SUPPORT)
...@@ -208,63 +217,65 @@ if (NOT DLIB_ISO_CPP_ONLY) ...@@ -208,63 +217,65 @@ if (NOT DLIB_ISO_CPP_ONLY)
target_link_libraries(dlib ${dlib_needed_libraries} ) target_link_libraries(dlib ${dlib_needed_libraries} )
endif () ##### end of if NOT DLIB_ISO_CPP_ONLY ########################################################## endif () ##### end of if NOT DLIB_ISO_CPP_ONLY ##########################################################
#test for some things that really should be true about the compiler #test for some things that really should be true about the compiler
include(TestForSTDNamespace) include(TestForSTDNamespace)
include(TestForANSIStreamHeaders) include(TestForANSIStreamHeaders)
if (DLIB_LINK_WITH_LIBPNG AND NOT DLIB_ISO_CPP_ONLY) if (DLIB_LINK_WITH_LIBPNG AND NOT DLIB_ISO_CPP_ONLY)
add_global_define(DLIB_PNG_SUPPORT) add_global_define(DLIB_PNG_SUPPORT)
else() else()
remove_global_define(DLIB_PNG_SUPPORT) remove_global_define(DLIB_PNG_SUPPORT)
endif() endif()
if (DLIB_LINK_WITH_LIBJPEG AND NOT DLIB_ISO_CPP_ONLY) if (DLIB_LINK_WITH_LIBJPEG AND NOT DLIB_ISO_CPP_ONLY)
add_global_define(DLIB_JPEG_SUPPORT) add_global_define(DLIB_JPEG_SUPPORT)
else() else()
remove_global_define(DLIB_JPEG_SUPPORT) remove_global_define(DLIB_JPEG_SUPPORT)
endif() endif()
if (DLIB_USE_BLAS AND blas_found) if (DLIB_USE_BLAS AND blas_found)
add_global_define(DLIB_USE_BLAS) add_global_define(DLIB_USE_BLAS)
else() else()
remove_global_define(DLIB_USE_BLAS) remove_global_define(DLIB_USE_BLAS)
endif() endif()
if (DLIB_USE_LAPACK AND lapack_found) if (DLIB_USE_LAPACK AND lapack_found)
add_global_define(DLIB_USE_LAPACK) add_global_define(DLIB_USE_LAPACK)
else() else()
remove_global_define(DLIB_USE_LAPACK) remove_global_define(DLIB_USE_LAPACK)
endif() endif()
if (DLIB_ISO_CPP_ONLY) if (DLIB_ISO_CPP_ONLY)
add_global_define(DLIB_ISO_CPP_ONLY) add_global_define(DLIB_ISO_CPP_ONLY)
else() else()
remove_global_define(DLIB_ISO_CPP_ONLY) remove_global_define(DLIB_ISO_CPP_ONLY)
endif() endif()
if (DLIB_NO_GUI_SUPPORT) if (DLIB_NO_GUI_SUPPORT)
add_global_define(DLIB_NO_GUI_SUPPORT) add_global_define(DLIB_NO_GUI_SUPPORT)
else() else()
remove_global_define(DLIB_NO_GUI_SUPPORT) remove_global_define(DLIB_NO_GUI_SUPPORT)
endif() endif()
if (DLIB_ENABLE_STACK_TRACE) if (DLIB_ENABLE_STACK_TRACE)
add_global_define(DLIB_ENABLE_STACK_TRACE) add_global_define(DLIB_ENABLE_STACK_TRACE)
else() else()
remove_global_define(DLIB_ENABLE_STACK_TRACE) remove_global_define(DLIB_ENABLE_STACK_TRACE)
endif() endif()
if (DLIB_ENABLE_ASSERTS) if (DLIB_ENABLE_ASSERTS)
add_global_define(ENABLE_ASSERTS) add_global_define(ENABLE_ASSERTS)
else() else()
remove_global_define(ENABLE_ASSERTS) remove_global_define(ENABLE_ASSERTS)
endif() endif()
endif()
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