forked from nvpro-pipeline/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
163 lines (128 loc) · 4.79 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
cmake_minimum_required(VERSION 2.8)
PROJECT( Pipeline )
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(WIN32)
SET( BUILD_DPT ON CACHE BOOL "Build the test framework" )
endif(WIN32)
if(WIN32 AND MSVC_VERSION LESS 1700)
SET( USE_CUDA ON CACHE BOOL "Use the CUDA library" )
else()
SET( USE_CUDA OFF CACHE BOOL "Use the CUDA library" )
endif()
if( USE_CUDA )
add_definitions("-DDP_USE_CUDA")
endif()
SET( USE_BOOST ON CACHE BOOL "Use the Boost 3rd party library" )
# check for DPHOME environment variable
if ( "$ENV{DPHOME}" STREQUAL "" )
message( FATAL_ERROR "DPHOME environment variable not set!" )
endif()
file(TO_CMAKE_PATH "$ENV{DPHOME}" DP_HOME)
# check for DP_3RDPARTY_PATH environment variable
if ( "$ENV{DP_3RDPARTY_PATH}" STREQUAL "" )
message( FATAL_ERROR "DP_3RDPARTY_PATH environment variable not set!" )
endif()
file(TO_CMAKE_PATH "$ENV{DP_3RDPARTY_PATH}" DP_3RDPARTY_PATH)
file(TO_CMAKE_PATH "$ENV{BUILD_TOOLS_DIR}" BUILD_TOOLS_DIR)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake" "${DP_3RDPARTY_PATH}/CMake")
if ( "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
set(DP_ARCH "${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "CPU Architecture" )
elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set (DP_ARCH "amd64" CACHE STRING "CPU Architecture")
else ()
set (DP_ARCH "x86" CACHE STRING "CPU Architecture")
endif()
find_package( NVBoost )
find_package( Boost REQUIRED )
if(MSVC10)
set (CRT "crt100")
#enable multiprocessor build on visual studio 2010
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
elseif(MSVC11)
set (CRT "crt110")
#enable multiprocessor build on visual studio 2012
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
#else()
# message(FATAL_ERROR "Compiler version not supported")
endif()
if(UNIX)
set(OS "linux")
add_definitions("-DLINUX")
add_definitions("-Wno-unused-local-typedefs -Wno-delete-non-virtual-dtor")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
else(UNIX)
if(APPLE)
else(APPLE)
if(WIN32)
set(OS "win")
add_definitions("-DNOMINMAX")
endif(WIN32)
endif(APPLE)
endif(UNIX)
if ("${CMAKE_GENERATOR}" MATCHES "^(Visual Studio).*")
set (DP_CONFIG "$(ConfigurationName)")
else()
if( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
set (DP_CONFIG "release")
endif()
endif()
if ( ${DP_ARCH} STREQUAL "armv7l" )
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard -mfpu=neon" )
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard -mfpu=neon")
endif()
if(UNIX)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
if (DP_ARCH STREQUAL "amd64")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
endif()
endif()
#set binary directory
if(WIN32 AND "${CMAKE_GENERATOR}" MATCHES "^(Visual Studio).*")
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin" )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin" )
else()
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/${DP_CONFIG}" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${DP_CONFIG}" )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${DP_CONFIG}" )
endif()
set(DP_BINARY_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DP_CONFIG}" CACHE STRING "Devtech Platform binary path")
set(DP_TEST_LAUNCH_SITE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release")
# some useful macros
MACRO(ADD_TARGET_PROPERTIES _target _name)
SET(_properties)
FOREACH(_prop ${ARGN})
SET(_properties "${_properties} ${_prop}")
ENDFOREACH(_prop)
GET_TARGET_PROPERTY(_old_properties ${_target} ${_name})
IF(NOT _old_properties)
# in case it's NOTFOUND
SET(_old_properties)
ENDIF(NOT _old_properties)
SET_TARGET_PROPERTIES(${_target} PROPERTIES ${_name} "${_old_properties} ${_properties}")
ENDMACRO(ADD_TARGET_PROPERTIES)
MACRO(TARGET_INCLUDE_SYMBOL target symbol)
if (WIN32)
if ( DP_ARCH STREQUAL "amd64" )
add_target_properties( ${target} LINK_FLAGS /include:${symbol} )
elseif( DP_ARCH STREQUAL "x86" )
add_target_properties( ${target} LINK_FLAGS /include:_${symbol} )
endif()
endif()
if(UNIX)
add_target_properties( ${target} LINK_FLAGS "-Wl,--undefined=${symbol}" )
endif()
ENDMACRO()
include_directories(${DP_HOME})
include_directories(${Boost_INCLUDE_DIR})
# find some libraries
if (WIN32)
find_package(NVPMAPI REQUIRED)
add_definitions("-DHAVE_NVPMAPI")
endif()
add_subdirectory( dp )
if( WIN32 AND BUILD_DPT )
add_subdirectory( test )
endif()
add_subdirectory( apps )