-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
96 lines (70 loc) · 2.76 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
cmake_minimum_required(VERSION 2.8)
project(marshmallow_h)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
######################################################################## CMAKE #
option(BUILD_SHARED_LIBS "Build a shared library" ON)
option(BUILD_UNIT_TESTS "Build unit tests" OFF)
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
####################################################################### GLOBAL #
if(BUILD_UNIT_TESTS)
enable_testing()
endif(BUILD_UNIT_TESTS)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-fno-rtti -fno-exceptions -ffast-math ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "-fomit-frame-pointer ${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS "-ffast-math ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "-fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()
if(NOT BUILD_SHARED_LIBS)
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib;.dll)
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a;.so)
endif()
endif()
if(UNIX)
find_package(M REQUIRED)
else()
set(M_LIBRARY)
endif()
############################################################### GLOBAL OPTIONS #
set(MARSHMALLOW_NAMESPACE "Marshmallow" CACHE STRING "Marshmallow Namespace")
option(MARSHMALLOW_DEBUG "Marshmallow Debugging" OFF)
set(MARSHMALLOW_DEBUG_VERBOSITY "0" CACHE STRING "Verbosity Level")
##################################################################### INCLUDES #
include_directories(${PROJECT_BINARY_DIR}/src
${PROJECT_SOURCE_DIR}/include
)
############################################################## SUB DIRECTORIES #
add_subdirectory(contrib)
add_subdirectory(src)
####################################################################### TARGET #
if(EXISTS ${PROJECT_SOURCE_DIR}/target/CMakeLists.txt)
add_subdirectory(target)
elseif(EXISTS ${PROJECT_SOURCE_DIR}/demos/CMakeLists.txt)
add_subdirectory(demos)
else()
set(MARSHMALLOW_LIBRARY_ONLY ON)
endif()
###################################################################### INSTALL #
# marshmallow headers
install(DIRECTORY include/
DESTINATION include/marshmallow_h
COMPONENT development)
# deployment
if(NOT MARSHMALLOW_LIBRARY_ONLY AND UNIX)
install(FILES resources/unix/run
DESTINATION .
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
COMPONENT deployment)
endif()