-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
143 lines (104 loc) · 4.53 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
# setup default build type (has to be done before 'PROJECT(...)' command)
IF(DEFINED CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: Debug Release.")
ELSE()
SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: Debug Release.")
ENDIF()
# start project
PROJECT(AisDecoder)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
SET(CMAKE_CONFIGURATION_TYPES Debug Release CACHE TYPE INTERNAL FORCE)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
IF(WIN32)
# using custom package paths
SET(WIN32_3RDPARTY_INCLUDE "C:/packages/include" CACHE PATH "")
SET(WIN32_3RDPARTY_LIBS "C:/packages/lib" CACHE PATH "")
ENDIF(WIN32)
SET(AIS_LIB_INSTALL_PATH "lib" CACHE PATH "System path to install library to -- prefixed with CMAKE_INSTALL_PREFIX.")
SET(AIS_SRC_INSTALL_PATH "include" CACHE PATH "System path to install header files to -- prefixed with CMAKE_INSTALL_PREFIX.")
message("Build tool: " ${CMAKE_BUILD_TOOL})
# setup system/cmake config flags based on target platform
IF(WIN32)
SET(TARGET_OS "Windows")
SET(TARGET_OS_ID "")
SET(TARGET_OS_CODENAME "")
ENDIF(WIN32)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(TARGET_OS "Mac OS")
SET(TARGET_OS_ID "Darwin")
SET(TARGET_OS_CODENAME "")
SET(MACX ON)
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym" CACHE STRING "")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(TARGET_OS "Linux")
# find Linux flavour (sets TARGET_OS_ID and TARGET_OS_CODENAME)
find_program(LSB_RELEASE lsb_release)
execute_process(COMMAND ${LSB_RELEASE} -is
OUTPUT_VARIABLE TARGET_OS_ID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${LSB_RELEASE} -cs
OUTPUT_VARIABLE TARGET_OS_CODENAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
SET(LINUX ON)
# detect Raspbian
IF(${TARGET_OS_ID} MATCHES "Raspbian")
SET(RASPBIAN ON)
message("Raspbian Detected")
ENDIF(${TARGET_OS_ID} MATCHES "Raspbian")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message("Target OS: " ${TARGET_OS})
message("Target OS Flavour: " ${TARGET_OS_ID})
message("Target OS Codename: " ${TARGET_OS_CODENAME})
# compiler general include folders
SET(PATH_EXAMPLE_DATA "${CMAKE_CURRENT_LIST_DIR}/data" CACHE PATH "Data folder used by example applications.")
IF(WIN32)
INCLUDE_DIRECTORIES(${WIN32_3RDPARTY_INCLUDE})
ELSE(WIN32)
IF(MACX)
INCLUDE_DIRECTORIES(/usr/local/include /opt/local/include)
ELSE(MACX)
INCLUDE_DIRECTORIES(/usr/include)
ENDIF(MACX)
ENDIF(WIN32)
# requires C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# setup some general compiler settings for target platform
IF(MSVC)
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /D_UNICODE /DUNICODE /D _CRT_SECURE_NO_DEPRECATE /wd4996 /W4 /WX /permissive-")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_UNICODE /DUNICODE /D _CRT_SECURE_NO_DEPRECATE /wd4996 /W4 /WX /DDEBUG /permissive-")
ELSE(MSVC)
IF(MACX)
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -Wall")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -Wall -DDEBUG")
ELSE(MACX)
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wno-unknown-pragmas -rdynamic")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -Wall -Wno-unknown-pragmas -DDEBUG -rdynamic")
ENDIF(MACX)
ENDIF(MSVC)
# setup more compiler flags (NDEBUG, DEBUG)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS EXAMPLE_DATA_PATH="${PATH_EXAMPLE_DATA}")
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG DEBUG=1)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_RELEASE NDEBUG=1)
# capture project/build/test files (not compiled, but visible in solutions)
set(PROJ_FILES
${CMAKE_SOURCE_DIR}/README.md
${CMAKE_SOURCE_DIR}/.gitignore
${CMAKE_SOURCE_DIR}/examples/example_utils.h
${CMAKE_SOURCE_DIR}/python/ais_decoder.i
${CMAKE_SOURCE_DIR}/python/setup.py
)
add_custom_target(proj_files SOURCES ${PROJ_FILES})
set_source_files_properties(${PROJ_FILES} PROPERTIES HEADER_FILE_ONLY TRUE)
# include source
add_subdirectory("ais_decoder")
add_subdirectory("examples/file_reader")
add_subdirectory("examples/file_reader_mt")
add_subdirectory("examples/quick")
add_subdirectory("examples/type123_meta")
add_subdirectory("examples/nmea2nmea")