-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathCMakeLists.txt
82 lines (67 loc) · 2.5 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
cmake_minimum_required(VERSION 3.20)
project(PatternLanguage)
set(CMAKE_CXX_STANDARD 23)
option(LIBPL_SHARED_LIBRARY "Compile the library as a shared library" OFF)
option(LIBPL_ENABLE_TESTS "Enable testing" OFF)
option(LIBPL_ENABLE_CLI "Enable building the CLI tool" ON)
option(LIBPL_BUILD_CLI_AS_EXECUTABLE "Build the CLI tool as an executable" ON)
option(LIBPL_ENABLE_EXAMPLE "Enable building the examples" OFF)
option(LIBPL_ENABLE_PRECOMPILED_HEADERS "Enable building with precompiled headers" OFF)
# if enabled, add a unit_test custom target for all the unit tests to be registered against
if (LIBPL_ENABLE_TESTS)
if(NOT TARGET unit_tests)
enable_testing()
add_custom_target(unit_tests)
endif()
endif ()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow -Wno-dangling-reference -fexceptions -frtti")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -fexceptions -frtti")
elseif (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-array-bounds")
endif()
if (CMAKE_CXX_COMPILER MATCHES "\\/em\\+\\+(-[a-zA-Z0-9.])?$")
add_compile_definitions(OS_WEB)
elseif (WIN32)
add_compile_definitions(OS_WINDOWS)
elseif (APPLE)
add_compile_definitions(OS_MACOS)
elseif (UNIX AND NOT APPLE)
add_compile_definitions(OS_LINUX)
endif ()
if (NOT USE_SYSTEM_FMT)
if (NOT TARGET fmt::fmt)
add_subdirectory(external/fmt EXCLUDE_FROM_ALL)
set(FMT_LIBRARIES fmt::fmt-header-only)
endif ()
else()
find_package(fmt 8.0.0 REQUIRED)
set(FMT_LIBRARIES fmt::fmt)
endif()
if (NOT USE_SYSTEM_NLOHMANN_JSON)
if (NOT TARGET nlohmann_json)
add_subdirectory(external/nlohmann_json EXCLUDE_FROM_ALL)
set(NLOHMANN_JSON_LIBRARIES nlohmann_json)
endif ()
else()
find_package(nlohmann_json 3.10.2 REQUIRED)
set(NLOHMANN_JSON_LIBRARIES nlohmann_json::nlohmann_json)
endif ()
add_subdirectory(external/libwolv)
add_subdirectory(lib)
add_subdirectory(generators EXCLUDE_FROM_ALL)
if (LIBPL_ENABLE_EXAMPLE)
add_subdirectory(example EXCLUDE_FROM_ALL)
endif ()
if (LIBPL_ENABLE_TESTS)
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif ()
if (LIBPL_ENABLE_CLI)
add_subdirectory(cli)
endif ()
if (LIBPL_ENABLE_FUZZING)
add_subdirectory(fuzz EXCLUDE_FROM_ALL)
endif ()
add_library(pl::libpl ALIAS libpl)