From 4de8678b57552458d75a6f3da0175d048acfe401 Mon Sep 17 00:00:00 2001 From: Davis King Date: Tue, 28 Jun 2016 20:17:03 -0400 Subject: [PATCH] Moved the auxiliary cmake into a common folder. --HG-- rename : dlib/add_global_compiler_switch.cmake => dlib/cmake_utils/add_global_compiler_switch.cmake rename : dlib/add_python_module => dlib/cmake_utils/add_python_module rename : dlib/cmake_find_blas.txt => dlib/cmake_utils/cmake_find_blas.txt rename : dlib/dlib.pc.in => dlib/cmake_utils/dlib.pc.in rename : dlib/dlibConfig.cmake.in => dlib/cmake_utils/dlibConfig.cmake.in rename : dlib/release_build_by_default => dlib/cmake_utils/release_build_by_default rename : dlib/tell_visual_studio_to_use_static_runtime.cmake => dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake rename : dlib/dnn/test_for_cpp11/CMakeLists.txt => dlib/cmake_utils/test_for_cpp11/CMakeLists.txt rename : dlib/dnn/test_for_cpp11/cpp11_test.cpp => dlib/cmake_utils/test_for_cpp11/cpp11_test.cpp rename : dlib/dnn/test_for_cuda/CMakeLists.txt => dlib/cmake_utils/test_for_cuda/CMakeLists.txt rename : dlib/dnn/test_for_cuda/cuda_test.cu => dlib/cmake_utils/test_for_cuda/cuda_test.cu rename : dlib/dnn/test_for_cudnn/CMakeLists.txt => dlib/cmake_utils/test_for_cudnn/CMakeLists.txt rename : dlib/dnn/test_for_cudnn/find_cudnn.txt => dlib/cmake_utils/test_for_cudnn/find_cudnn.txt rename : dlib/use_cpp_11.cmake => dlib/cmake_utils/use_cpp_11.cmake --- dlib/CMakeLists.txt | 18 +++++++++--------- dlib/cmake | 8 ++++---- .../add_global_compiler_switch.cmake | 0 dlib/{ => cmake_utils}/add_python_module | 6 ++---- dlib/{ => cmake_utils}/cmake_find_blas.txt | 0 dlib/{ => cmake_utils}/dlib.pc.in | 0 dlib/{ => cmake_utils}/dlibConfig.cmake.in | 1 + .../{ => cmake_utils}/release_build_by_default | 0 ...l_visual_studio_to_use_static_runtime.cmake | 0 .../test_for_cpp11/CMakeLists.txt | 0 .../test_for_cpp11/cpp11_test.cpp | 0 .../test_for_cuda/CMakeLists.txt | 2 +- .../test_for_cuda/cuda_test.cu | 0 .../test_for_cudnn/CMakeLists.txt | 4 ++-- .../test_for_cudnn/find_cudnn.txt | 0 dlib/{ => cmake_utils}/use_cpp_11.cmake | 6 ++---- tools/python/CMakeLists.txt | 2 +- 17 files changed, 22 insertions(+), 25 deletions(-) rename dlib/{ => cmake_utils}/add_global_compiler_switch.cmake (100%) rename dlib/{ => cmake_utils}/add_python_module (96%) rename dlib/{ => cmake_utils}/cmake_find_blas.txt (100%) rename dlib/{ => cmake_utils}/dlib.pc.in (100%) rename dlib/{ => cmake_utils}/dlibConfig.cmake.in (96%) rename dlib/{ => cmake_utils}/release_build_by_default (100%) rename dlib/{ => cmake_utils}/tell_visual_studio_to_use_static_runtime.cmake (100%) rename dlib/{dnn => cmake_utils}/test_for_cpp11/CMakeLists.txt (100%) rename dlib/{dnn => cmake_utils}/test_for_cpp11/cpp11_test.cpp (100%) rename dlib/{dnn => cmake_utils}/test_for_cuda/CMakeLists.txt (90%) rename dlib/{dnn => cmake_utils}/test_for_cuda/cuda_test.cu (100%) rename dlib/{dnn => cmake_utils}/test_for_cudnn/CMakeLists.txt (71%) rename dlib/{dnn => cmake_utils}/test_for_cudnn/find_cudnn.txt (100%) rename dlib/{ => cmake_utils}/use_cpp_11.cmake (93%) diff --git a/dlib/CMakeLists.txt b/dlib/CMakeLists.txt index e0753883a..acefd9538 100644 --- a/dlib/CMakeLists.txt +++ b/dlib/CMakeLists.txt @@ -8,8 +8,8 @@ cmake_minimum_required(VERSION 2.8.4) project(dlib) # default to a Release build (except if CMAKE_BUILD_TYPE is set) -include(release_build_by_default) -include(use_cpp_11.cmake) +include(cmake_utils/release_build_by_default) +include(cmake_utils/use_cpp_11.cmake) set(CPACK_PACKAGE_VERSION_MAJOR "19") @@ -31,7 +31,7 @@ if(COMMAND cmake_policy) endif() endif() -include(add_global_compiler_switch.cmake) +include(cmake_utils/add_global_compiler_switch.cmake) # Make sure ENABLE_ASSERTS is defined for debug builds @@ -424,7 +424,7 @@ if (NOT TARGET dlib) if (DLIB_USE_BLAS OR DLIB_USE_LAPACK) # Try to find BLAS and LAPACK - include(cmake_find_blas.txt) + include(cmake_utils/cmake_find_blas.txt) if (DLIB_USE_BLAS) if (blas_found) @@ -458,13 +458,13 @@ if (NOT TARGET dlib) # linux). list(APPEND CUDA_NVCC_FLAGS "-arch=sm_30;-std=c++11;-D__STRICT_ANSI__") - include(dnn/test_for_cudnn/find_cudnn.txt) + include(cmake_utils/test_for_cudnn/find_cudnn.txt) if (cudnn AND NOT DEFINED cuda_test_compile_worked AND NOT DEFINED cudnn_test_compile_worked) # make sure cuda is really working by doing a test compile message(STATUS "Building a CUDA test project to see if your compiler is compatible with CUDA...") try_compile(cuda_test_compile_worked ${PROJECT_BINARY_DIR}/cuda_test_build - ${PROJECT_SOURCE_DIR}/dnn/test_for_cuda cuda_test + ${PROJECT_SOURCE_DIR}/cmake_utils/test_for_cuda cuda_test CMAKE_FLAGS "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" "-DCMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}" "-DCMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}" @@ -474,7 +474,7 @@ if (NOT TARGET dlib) else() message(STATUS "Checking if you have the right version of cuDNN installed.") try_compile(cudnn_test_compile_worked ${PROJECT_BINARY_DIR}/cudnn_test_build - ${PROJECT_SOURCE_DIR}/dnn/test_for_cudnn cudnn_test + ${PROJECT_SOURCE_DIR}/cmake_utils/test_for_cudnn cudnn_test CMAKE_FLAGS "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" "-DCMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}" "-DCMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}" @@ -610,7 +610,7 @@ if (NOT TARGET dlib) DESTINATION ${ConfigPackageLocation}) set(CONF_INSTALL_PATH "\${dlib_CMAKE_DIR}/../../../") - configure_file(dlibConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/config/dlibConfig.cmake" @ONLY) + configure_file(cmake_utils/dlibConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/config/dlibConfig.cmake" @ONLY) include(CMakePackageConfigHelpers) write_basic_package_version_file( @@ -626,7 +626,7 @@ if (NOT TARGET dlib) ## dlib-1.pc generation and installation - configure_file("dlib.pc.in" "dlib-1.pc" @ONLY) + configure_file("cmake_utils/dlib.pc.in" "dlib-1.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dlib-1.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") diff --git a/dlib/cmake b/dlib/cmake index e13d04cca..3ccd4897c 100644 --- a/dlib/cmake +++ b/dlib/cmake @@ -12,9 +12,9 @@ endif() # Determine the path to dlib. -string(REGEX REPLACE "cmake$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE}) -include(${dlib_path}/add_global_compiler_switch.cmake) -include(${dlib_path}/use_cpp_11.cmake) +set(dlib_path ${CMAKE_CURRENT_LIST_DIR}) +include(${dlib_path}/cmake_utils/add_global_compiler_switch.cmake) +include(${dlib_path}/cmake_utils/use_cpp_11.cmake) if (CMAKE_COMPILER_IS_GNUCXX) # By default, g++ won't warn or error if you forget to return a value in a @@ -92,7 +92,7 @@ INCLUDE_DIRECTORIES(${dlib_path}/..) # This is really optional, but nice. It will make sure the build mode # created by cmake is always release by default. -include(${dlib_path}/release_build_by_default) +include(${dlib_path}/cmake_utils/release_build_by_default) # Don't add dlib if it's already been added to the cmake project diff --git a/dlib/add_global_compiler_switch.cmake b/dlib/cmake_utils/add_global_compiler_switch.cmake similarity index 100% rename from dlib/add_global_compiler_switch.cmake rename to dlib/cmake_utils/add_global_compiler_switch.cmake diff --git a/dlib/add_python_module b/dlib/cmake_utils/add_python_module similarity index 96% rename from dlib/add_python_module rename to dlib/cmake_utils/add_python_module index d5c3dbcef..2f0f8a415 100644 --- a/dlib/add_python_module +++ b/dlib/cmake_utils/add_python_module @@ -40,8 +40,7 @@ set(CMAKE_PREFIX_PATH ${PYTHON_PATH}) # of other dll files and can be safely copied to someone elese's computer # and expected to run. if (MSVC) - string(REGEX REPLACE "add_python_module$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE}) - include(${dlib_path}/tell_visual_studio_to_use_static_runtime.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/tell_visual_studio_to_use_static_runtime.cmake) add_definitions(-DBOOST_PYTHON_STATIC_LIB) SET(Boost_USE_STATIC_LIBS ON) SET(Boost_USE_MULTITHREADED ON) @@ -130,8 +129,7 @@ else() endif() # include dlib so we can link against it -string(REGEX REPLACE "add_python_module$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE}) -include(${dlib_path}/cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../cmake) # We put the extra _ on the end of the name just so it's possible to diff --git a/dlib/cmake_find_blas.txt b/dlib/cmake_utils/cmake_find_blas.txt similarity index 100% rename from dlib/cmake_find_blas.txt rename to dlib/cmake_utils/cmake_find_blas.txt diff --git a/dlib/dlib.pc.in b/dlib/cmake_utils/dlib.pc.in similarity index 100% rename from dlib/dlib.pc.in rename to dlib/cmake_utils/dlib.pc.in diff --git a/dlib/dlibConfig.cmake.in b/dlib/cmake_utils/dlibConfig.cmake.in similarity index 96% rename from dlib/dlibConfig.cmake.in rename to dlib/cmake_utils/dlibConfig.cmake.in index a2d2ec596..3c6da98a6 100644 --- a/dlib/dlibConfig.cmake.in +++ b/dlib/cmake_utils/dlibConfig.cmake.in @@ -37,3 +37,4 @@ endif() find_library(dlib_LIBRARIES dlib HINTS ${dlib_INSTALL_PATH}/lib) set(dlib_LIBRARIES ${dlib_LIBRARIES} "@dlib_needed_libraries@") +set(dlib_LIBS ${dlib_LIBRARIES} "@dlib_needed_libraries@") diff --git a/dlib/release_build_by_default b/dlib/cmake_utils/release_build_by_default similarity index 100% rename from dlib/release_build_by_default rename to dlib/cmake_utils/release_build_by_default diff --git a/dlib/tell_visual_studio_to_use_static_runtime.cmake b/dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake similarity index 100% rename from dlib/tell_visual_studio_to_use_static_runtime.cmake rename to dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake diff --git a/dlib/dnn/test_for_cpp11/CMakeLists.txt b/dlib/cmake_utils/test_for_cpp11/CMakeLists.txt similarity index 100% rename from dlib/dnn/test_for_cpp11/CMakeLists.txt rename to dlib/cmake_utils/test_for_cpp11/CMakeLists.txt diff --git a/dlib/dnn/test_for_cpp11/cpp11_test.cpp b/dlib/cmake_utils/test_for_cpp11/cpp11_test.cpp similarity index 100% rename from dlib/dnn/test_for_cpp11/cpp11_test.cpp rename to dlib/cmake_utils/test_for_cpp11/cpp11_test.cpp diff --git a/dlib/dnn/test_for_cuda/CMakeLists.txt b/dlib/cmake_utils/test_for_cuda/CMakeLists.txt similarity index 90% rename from dlib/dnn/test_for_cuda/CMakeLists.txt rename to dlib/cmake_utils/test_for_cuda/CMakeLists.txt index fb392688c..94f1bfeb6 100644 --- a/dlib/dnn/test_for_cuda/CMakeLists.txt +++ b/dlib/cmake_utils/test_for_cuda/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.4) project(cuda_test) -include_directories(..) +include_directories(../../dnn) add_definitions(-DDLIB_USE_CUDA) find_package(CUDA 7.5 REQUIRED) diff --git a/dlib/dnn/test_for_cuda/cuda_test.cu b/dlib/cmake_utils/test_for_cuda/cuda_test.cu similarity index 100% rename from dlib/dnn/test_for_cuda/cuda_test.cu rename to dlib/cmake_utils/test_for_cuda/cuda_test.cu diff --git a/dlib/dnn/test_for_cudnn/CMakeLists.txt b/dlib/cmake_utils/test_for_cudnn/CMakeLists.txt similarity index 71% rename from dlib/dnn/test_for_cudnn/CMakeLists.txt rename to dlib/cmake_utils/test_for_cudnn/CMakeLists.txt index 421af0d55..c55c098e1 100644 --- a/dlib/dnn/test_for_cudnn/CMakeLists.txt +++ b/dlib/cmake_utils/test_for_cudnn/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8.4) project(cudnn_test) -include(../../use_cpp_11.cmake) +include(../use_cpp_11.cmake) find_package(CUDA 7.5 REQUIRED) set(CUDA_HOST_COMPILATION_CPP ON) @@ -12,4 +12,4 @@ include(find_cudnn.txt) include_directories(${cudnn_include}) -cuda_add_library(cudnn_test STATIC ../cudnn_dlibapi.cpp ${cudnn} ) +cuda_add_library(cudnn_test STATIC ../../dnn/cudnn_dlibapi.cpp ${cudnn} ) diff --git a/dlib/dnn/test_for_cudnn/find_cudnn.txt b/dlib/cmake_utils/test_for_cudnn/find_cudnn.txt similarity index 100% rename from dlib/dnn/test_for_cudnn/find_cudnn.txt rename to dlib/cmake_utils/test_for_cudnn/find_cudnn.txt diff --git a/dlib/use_cpp_11.cmake b/dlib/cmake_utils/use_cpp_11.cmake similarity index 93% rename from dlib/use_cpp_11.cmake rename to dlib/cmake_utils/use_cpp_11.cmake index 2203634de..9e48c6b7b 100644 --- a/dlib/use_cpp_11.cmake +++ b/dlib/cmake_utils/use_cpp_11.cmake @@ -16,9 +16,7 @@ endif() # Set to false unless we find out otherwise in the code below. set(COMPILER_CAN_DO_CPP_11 0) -# Determine the path to dlib. -string(REGEX REPLACE "use_cpp_11.cmake$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE}) -include(${dlib_path}/add_global_compiler_switch.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/add_global_compiler_switch.cmake) # Now turn on the appropriate compiler switch to enable C++11 if you have a @@ -44,7 +42,7 @@ if (CMAKE_VERSION VERSION_LESS "3.1.2") # Since we don't know what compiler this is ust try to build a c++11 project and see if it compiles. message(STATUS "Building a C++11 test project to see if your compiler supports C++11") try_compile(test_for_cpp11_worked ${PROJECT_BINARY_DIR}/cpp11_test_build - ${dlib_path}/dnn/test_for_cpp11 cpp11_test) + ${CMAKE_CURRENT_LIST_DIR}/test_for_cpp11 cpp11_test) if (test_for_cpp11_worked) message(STATUS "C++11 activated.") set(COMPILER_CAN_DO_CPP_11 1) diff --git a/tools/python/CMakeLists.txt b/tools/python/CMakeLists.txt index 062dc443d..b7075ab99 100644 --- a/tools/python/CMakeLists.txt +++ b/tools/python/CMakeLists.txt @@ -3,7 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4) set(USE_SSE4_INSTRUCTIONS ON CACHE BOOL "Use SSE4 instructions") -include(../../dlib/add_python_module) +include(../../dlib/cmake_utils/add_python_module) add_definitions(-DDLIB_VERSION=${DLIB_VERSION})