-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (86 loc) · 4.63 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
#
# Copyright (c) Honda Research Institute Europe GmbH
#
# This file is part of ToolBOSLib.
#
# ToolBOSLib is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ToolBOSLib is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ToolBOSLib. If not, see <http://www.gnu.org/licenses/>.
#
#
#----------------------------------------------------------------------------
# Standard header + common routines
#----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
project(ToolBOSLib)
find_package(BuildSystemTools)
set(BST_INSTALL_CATEGORY Libraries)
#----------------------------------------------------------------------------
# Dependencies
#----------------------------------------------------------------------------
bst_find_package(External/msinttypes/1.0)
bst_find_package(External/pthreads4w/1.0)
# do not include cutest here, otherwise the library will link against it
# although not needed
#----------------------------------------------------------------------------
# Build specification
#----------------------------------------------------------------------------
# The package binutils 2.34 (e.g. in Ubuntu 20.04) received an API change,
# see TBCORE-2160 for details.
if("$ENV{MAKEFILE_PLATFORM}" STREQUAL "focal64")
add_definitions(-DNEW_BFD_API)
endif()
add_definitions(-DTOOLBOS_MAJVERSION=${TARGET_VERSION_MAJOR}
-DTOOLBOS_MINVERSION=${TARGET_VERSION_MINOR}
-DHAVE_BFD_DEMANGLE
-D_DEFAULT_SOURCE)
# non-standard location for ToolBOS.conf.h
include_directories($ENV{TOOLBOSCORE_ROOT}/etc)
# the C90 standard recommends that C++ does not have INT_MAX etc. by default
# but we use them to define e.g. BASEI32_MAX
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS")
file(GLOB SRC_FILES src/*.c)
if(UNIX OR "$ENV{MAKEFILE_PLATFORM}" MATCHES "^mingw")
add_definitions(-D_POSIX_C_SOURCE=199506L -D__USE_MISC
-D__USE_XOPEN -D__USE_GNU -D_GNU_SOURCE -D_XOPEN_SOURCE=600)
if("$ENV{MAKEFILE_PLATFORM}" MATCHES "^mingw" )
list(APPEND BST_LIBRARIES_SHARED ws2_32.lib wsock32.lib shlwapi.lib winmm.lib psapi.lib)
else()
list(APPEND BST_LIBRARIES_SHARED bfd dl iberty m pthread rt)
endif()
else()
list(APPEND SRC_FILES ${PTHREADS4W_SRCDIR}/pthread.c)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H /D__CLEANUP_C /DWIN32 /DNDEBUG /D_WINDOWS /D_USRDLL /D__PTW32_STATIC_LIB /DPTW32_STATIC_LIB -I${TOOLBOSCORE_PTHREADS_DIRECTORY}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H /D__CLEANUP_C /DWIN32 /DNDEBUG /D_WINDOWS /D_USRDLL /D__PTW32_STATIC_LIB /DPTW32_STATIC_LIB -I${TOOLBOSCORE_PTHREADS_DIRECTORY}")
list(APPEND BST_LIBRARIES_SHARED ws2_32.lib wsock32.lib shlwapi.lib winmm.lib psapi.lib)
endif()
bst_build_libraries("${SRC_FILES}" "${PROJECT_NAME}" "${BST_LIBRARIES_SHARED}")
file(GLOB EXE_FILES examples/*.c examples/*.cpp)
bst_build_executables("${EXE_FILES}" "${BST_LIBRARIES_SHARED}")
if(EXISTS "$ENV{SIT}/External/cutest/1.5/lib/$ENV{MAKEFILE_PLATFORM}")
bst_find_package(External/cutest/1.5)
message("building tests for platform=$ENV{MAKEFILE_PLATFORM}")
set(EXE_FILES ${CMAKE_HOME_DIRECTORY}/test/AnyString/TestAnyString.c
${CMAKE_HOME_DIRECTORY}/test/BasicFunctions/TestBasicFunctions.cpp
${CMAKE_HOME_DIRECTORY}/test/ESC/TestESC.c
${CMAKE_HOME_DIRECTORY}/test/IOChannelLifecycle/TestIOChannelLifecycle.cpp
${CMAKE_HOME_DIRECTORY}/test/IOChannelMain/TestIOChannelMain.cpp
${CMAKE_HOME_DIRECTORY}/test/ListsAndQueues/TestListsAndQueues.cpp
${CMAKE_HOME_DIRECTORY}/test/Multithreading/TestMultithreading.cpp
${CMAKE_HOME_DIRECTORY}/test/SerializeHeaderRead/TestSerializeHeaderRead.cpp
${CMAKE_HOME_DIRECTORY}/test/SerializeHeaderWrite/TestSerializeHeaderWrite.cpp
${CMAKE_HOME_DIRECTORY}/test/WorkQueue/TestWorkQueue.cpp)
bst_build_executables("${EXE_FILES}" "${BST_LIBRARIES_SHARED}")
else()
message("skipping tests (CuTest not found for $ENV{MAKEFILE_PLATFORM})")
endif()
# EOF