-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
75 lines (63 loc) · 3.46 KB
/
CMakeLists.txt
File metadata and controls
75 lines (63 loc) · 3.46 KB
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
# Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.3)
project(mapcode_cpp)
# The debug configuration adds the "address sanitizer" to check for out of bounds behavior and such.
# You may wish to set the following environment variables during runtime as well:
#
# export ASAN_OPTIONS=debug=true:strict_string_checks=1:detect_stack_use_after_return=true:detect_invalid_pointer_pairs=99999:
# detect_container_overflow=true:detect_odr_violation=2:check_initialization_order=true
#
# Compiler directives (for internal use only):
#
# NO_POSIX_THREADS - No multi-threaded unit testing - only effective for unit test.
# NO_FAST_ENCODE - Drop fast encoding support - only for internal use.
set(MAPCODE_OPTIONS "")
set(MAPCODE_WARNING_OPTIONS "-Wall -Werror")
set(MAPCODE_SANITIZER_COMPILER_OPTIONS "-fsanitize=address -fno-common -fno-optimize-sibling-calls -fno-omit-frame-pointer")
set(MAPCODE_SANITIZER_LINKER_OPTIONS "-fsanitize=address")
set(CMAKE_C_FLAGS_DEBUG "${MAPCODE_OPTIONS} ${MAPCODE_WARNING_OPTIONS} ${MAPCODE_SANITIZER_COMPILER_OPTIONS} -O0 -g -DDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${MAPCODE_OPTIONS} ${MAPCODE_WARNING_OPTIONS} ${MAPCODE_SANITIZER_COMPILER_OPTIONS} -O2 -g -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${MAPCODE_OPTIONS} ${MAPCODE_WARNING_OPTIONS} -O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${MAPCODE_OPTIONS} ${MAPCODE_WARNING_OPTIONS} ${MAPCODE_SANITIZER_COMPILER_OPTIONS} -O0 -g -DDEBUG -std=c++11")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${MAPCODE_OPTIONS} ${MAPCODE_WARNING_OPTIONS} ${MAPCODE_SANITIZER_COMPILER_OPTIONS} -O2 -g -DNDEBUG -std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "${MAPCODE_OPTIONS} ${MAPCODE_WARNING_OPTIONS} -O3 -DNDEBUG -std=c++11")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${MAPCODE_SANITIZER_LINKER_OPTIONS}")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${MAPCODE_SANITIZER_LINKER_OPTIONS}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
set(SOURCE_FILES_MAPCODELIB
mapcodelib/internal_data.h
mapcodelib/internal_alphabet_recognizer.h
mapcodelib/internal_iso3166_data.h
mapcodelib/internal_territory_alphabets.h
mapcodelib/internal_territory_names_english.h
mapcodelib/internal_territory_names_local.h
mapcodelib/internal_territory_search.h
mapcodelib/mapcode_alphabets.h
mapcodelib/mapcode_legacy.c
mapcodelib/mapcode_legacy.h
mapcodelib/mapcode_territories.h
mapcodelib/mapcoder.c
mapcodelib/mapcoder.h)
set(SOURCE_FILES_UNITTEST
unittest/decode_test.h
unittest/unittest.c)
set(SOURCE_FILES_UTILITY
utility/mapcode.cpp)
add_library(mapcodelib ${SOURCE_FILES_MAPCODELIB})
target_include_directories(mapcodelib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(unittest ${SOURCE_FILES_UNITTEST})
target_link_libraries(unittest LINK_PUBLIC mapcodelib)
add_executable(mapcode ${SOURCE_FILES_UTILITY})
target_link_libraries(mapcode LINK_PUBLIC mapcodelib)