-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
154 lines (119 loc) · 4.48 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
cmake_minimum_required(VERSION 2.8)
PROJECT( Pipeline )
# check for DPHOME environment variable, use source root directory as fallback
if ( "$ENV{DPHOME}" STREQUAL "" )
set(DP_HOME "${CMAKE_SOURCE_DIR}")
else()
file(TO_CMAKE_PATH "$ENV{DPHOME}" DP_HOME)
endif()
# check for DP_3RDPARTY_PATH environment variable, use DPHOME/3rdparty as fallback
if ( "$ENV{DP_3RDPARTY_PATH}" STREQUAL "" )
set(DP_3RDPARTY_PATH "${DP_HOME}/3rdparty")
else()
file(TO_CMAKE_PATH "$ENV{DP_3RDPARTY_PATH}" DP_3RDPARTY_PATH)
endif()
add_definitions(-DDP_HOME_FALLBACK=\"${DP_HOME}\")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
include("dp")
include("dp3rdParty")
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" )
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")
find_package( Boost REQUIRED )
if(UNIX)
set(OS "linux")
add_definitions("-DLINUX")
add_definitions("-Wno-unused-local-typedefs -Wno-delete-non-virtual-dtor")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
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 (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
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(3rdparty)
add_subdirectory( dp )
if( WIN32 AND BUILD_DPT )
add_subdirectory( test )
endif()
add_subdirectory( apps )