Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
cd64c518
Commit
cd64c518
authored
Feb 16, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made cmake script work a little better in projects that involve a lot of
subdirectories and create a lot of executables.
parent
1f7bec6e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
57 deletions
+59
-57
cmake
dlib/cmake
+59
-57
No files found.
dlib/cmake
View file @
cd64c518
# This is a CMake file meant to be included via include()
cmake_minimum_required(VERSION 2.6.4)
cmake_minimum_required(VERSION 2.6.4)
...
@@ -7,75 +8,76 @@ if (POLICY CMP0054)
...
@@ -7,75 +8,76 @@ if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0054 NEW)
endif()
endif()
# Don't add dlib if it's already been added to the cmake project
if (NOT TARGET dlib)
# Determine the path to dlib.
# Determine the path to dlib.
string(REGEX REPLACE "cmake$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE})
string(REGEX REPLACE "cmake$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE})
if (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_COMPILER_IS_GNUCXX)
# By default, g++ won't warn or error if you forget to return a value in a
# By default, g++ won't warn or error if you forget to return a value in a
# function which requires you to do so. This option makes it give a warning
# function which requires you to do so. This option makes it give a warning
# for doing this.
# for doing this.
add_definitions("-Wreturn-type")
add_definitions("-Wreturn-type")
endif()
endif()
# Setup some options to allow a user to enable SSE and AVX instruction use.
# Setup some options to allow a user to enable SSE and AVX instruction use.
if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" OFF)
option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" OFF)
option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
if(USE_AVX_INSTRUCTIONS)
add_definitions(-mavx)
elseif (USE_SSE4_INSTRUCTIONS)
add_definitions(-msse4)
elseif(USE_SSE2_INSTRUCTIONS)
add_definitions(-msse2)
endif()
elseif (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # else if using Visual Studio
# Use SSE2 by default when using Visual Studio.
option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" ON)
# Visual Studio 2005 didn't support SSE4
if (NOT MSVC80)
option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
endif()
# Visual Studio 2005 and 2008 didn't support AVX
if (NOT MSVC80 AND NOT MSVC90)
option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
if(USE_AVX_INSTRUCTIONS)
endif()
add_definitions(-mavx)
include(CheckTypeSize)
elseif (USE_SSE4_INSTRUCTIONS)
check_type_size( "void*" SIZE_OF_VOID_PTR)
add_definitions(-msse4)
if(USE_AVX_INSTRUCTIONS)
elseif(USE_SSE2_INSTRUCTIONS)
add_definitions(/arch:AVX)
add_definitions(-msse2)
elseif (USE_SSE4_INSTRUCTIONS)
# Visual studio doesn't have an /arch:SSE2 flag when building in 64 bit modes.
# So only give it when we are doing a 32 bit build.
if (SIZE_OF_VOID_PTR EQUAL 4)
add_definitions(/arch:SSE2)
endif()
endif()
elseif (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # else if using Visual Studio
add_definitions(-DDLIB_HAVE_SSE2)
# Use SSE2 by default when using Visual Studio.
add_definitions(-DDLIB_HAVE_SSE3)
option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" ON)
add_definitions(-DDLIB_HAVE_SSE41)
# Visual Studio 2005 didn't support SSE4
elseif(USE_SSE2_INSTRUCTIONS)
if (NOT MSVC80)
# Visual studio doesn't have an /arch:SSE2 flag when building in 64 bit modes.
option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
# So only give it when we are doing a 32 bit build.
endif()
if (SIZE_OF_VOID_PTR EQUAL 4)
# Visual Studio 2005 and 2008 didn't support AVX
add_definitions(/arch:SSE2)
if (NOT MSVC80 AND NOT MSVC90)
option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
endif()
include(CheckTypeSize)
check_type_size( "void*" SIZE_OF_VOID_PTR)
if(USE_AVX_INSTRUCTIONS)
add_definitions(/arch:AVX)
elseif (USE_SSE4_INSTRUCTIONS)
# Visual studio doesn't have an /arch:SSE2 flag when building in 64 bit modes.
# So only give it when we are doing a 32 bit build.
if (SIZE_OF_VOID_PTR EQUAL 4)
add_definitions(/arch:SSE2)
endif()
add_definitions(-DDLIB_HAVE_SSE2)
add_definitions(-DDLIB_HAVE_SSE3)
add_definitions(-DDLIB_HAVE_SSE41)
elseif(USE_SSE2_INSTRUCTIONS)
# Visual studio doesn't have an /arch:SSE2 flag when building in 64 bit modes.
# So only give it when we are doing a 32 bit build.
if (SIZE_OF_VOID_PTR EQUAL 4)
add_definitions(/arch:SSE2)
endif()
add_definitions(-DDLIB_HAVE_SSE2)
endif()
endif()
add_definitions(-DDLIB_HAVE_SSE2)
endif()
endif()
endif()
# Add folder containing dlib to the include search path.
INCLUDE_DIRECTORIES(${dlib_path}/..)
# Add folder containing dlib to the include search path.
# This is really optional, but nice. It will make sure the build mode
INCLUDE_DIRECTORIES(${dlib_path}/..)
# created by cmake is always release by default.
include(${dlib_path}/release_build_by_default)
# 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)
# Don't add dlib if it's already been added to the cmake project
if (NOT TARGET dlib)
add_subdirectory(${dlib_path} dlib_build)
add_subdirectory(${dlib_path} dlib_build)
endif()
endif()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment