forked from uic-evl/omicron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (124 loc) · 5.67 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
set_property(GLOBAL PROPERTY USE_FOLDERS On)
cmake_minimum_required(VERSION 2.8.1)
project(OmicronSDK)
include(CPack)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
#cmake_policy(SET CMP0008 NEW)
endif()
if(APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++" CACHE STRING "" FORCE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -stdlib=libstdc++" CACHE STRING "" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++" CACHE STRING "" FORCE)
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -stdlib=libstdc++" CACHE STRING "" FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libstdc++" CACHE STRING "" FORCE)
endif(APPLE)
#-------------------------------------------------------------------------------
# Create a build name depending on the OS, Toolset and architecture.
if(CMAKE_GENERATOR STREQUAL "Visual Studio 12 2013")
set(OMICRON_OS_WIN 1)
set(OMICRON_ARCH_32 1)
set(OMICRON_ARCH_WIN32 1)
set(OMICRON_TOOL_VS12 1)
elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 14 2015")
set(OMICRON_OS_WIN 1)
set(OMICRON_ARCH_32 1)
set(OMICRON_ARCH_WIN32 1)
set(OMICRON_TOOL_VS14 1)
elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017")
set(OMICRON_OS_WIN 1)
set(OMICRON_ARCH_32 1)
set(OMICRON_ARCH_WIN32 1)
set(OMICRON_TOOL_VS14 1)
elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 12 2013 Win64")
set(OMICRON_OS_WIN 1)
set(OMICRON_ARCH_64 1)
set(OMICRON_ARCH_WIN32 1)
set(OMICRON_TOOL_VS12 1)
elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 14 2015 Win64")
set(OMICRON_OS_WIN 1)
set(OMICRON_ARCH_64 1)
set(OMICRON_ARCH_WIN32 1)
set(OMICRON_TOOL_VS14 1)
elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017 Win64")
set(OMICRON_OS_WIN 1)
set(OMICRON_ARCH_64 1)
set(OMICRON_ARCH_WIN32 1)
set(OMICRON_TOOL_VS14 1)
elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
if(APPLE)
set(OMICRON_OS_OSX 1)
set(OMICRON_ARCH_32 1)
set(OMICRON_ARCH_I386 1)
set(OMICRON_TOOL_GCC 1)
else()
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(OMICRON_OS_LINUX 1)
set(OMICRON_ARCH_64 1)
set(OMICRON_ARCH_AMD64 1)
set(OMICRON_TOOL_GCC 1)
else()
set(OMICRON_OS_LINUX 1)
set(OMICRON_ARCH_32 1)
set(OMICRON_ARCH_I386 1)
set(OMICRON_TOOL_GCC 1)
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ldl -lrt -pthread")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ldl -lrt -pthread")
endif()
elseif(CMAKE_GENERATOR STREQUAL "Xcode")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
set(OMICRON_OS_OSX 1)
set(OMICRON_ARCH_64 1)
set(OMICRON_ARCH_AMD64 1)
set(OMICRON_TOOL_GCC 1)
endif()
set(OMICRON_DATA_PATH "${CMAKE_SOURCE_DIR}/data")
################################################################################
# Set the output directories for libraries and binary files
if(OMICRON_USE_CUSTOM_OUTPUT)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OMICRON_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OMICRON_ARCHIVE_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OMICRON_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${OMICRON_LIBRARY_OUTPUT_DIRECTORY_DEBUG})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${OMICRON_LIBRARY_OUTPUT_DIRECTORY_RELEASE})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${OMICRON_LIBRARY_OUTPUT_DIRECTORY_RELEASE})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${OMICRON_ARCHIVE_OUTPUT_DIRECTORY_DEBUG})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${OMICRON_ARCHIVE_OUTPUT_DIRECTORY_RELEASE})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${OMICRON_ARCHIVE_OUTPUT_DIRECTORY_RELEASE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OMICRON_RUNTIME_OUTPUT_DIRECTORY_DEBUG})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OMICRON_RUNTIME_OUTPUT_DIRECTORY_RELEASE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${OMICRON_RUNTIME_OUTPUT_DIRECTORY_RELEASE})
else()
if(MSVC OR CMAKE_GENERATOR STREQUAL "Xcode")
# Since visual studio builds are multiconfiguration, set two separate directories for debug and release builds
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin/debug)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin/release)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib/debug)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib/release)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin/debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin/release)
# Make sure the output bin directories exist, so the cmake scripts can copy
# third party dlls there if needed.
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG})
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE})
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
file(MAKE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif()
endif()
################################################################################
# Visual studio specific options.
if(MSVC)
# Exclude libcmt when linking in visual studio
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB:libcmt.lib")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /NODEFAULTLIB:libcmt.lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /NODEFAULTLIB:libcmt.lib")
add_definitions(-D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4018)
endif(MSVC)
################################################################################
# Add subdirectiories
add_subdirectory(src)