-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
64 lines (56 loc) · 2.38 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
cmake_minimum_required(VERSION 3.12)
project(parsegen)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG_REDUCED_BUFFERS")
if(MSVC)
if(${MSVC_VERSION} GREATER_EQUAL "1920")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STRICT_ANSI__ -fno-rtti -Wall -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_ITERATOR_DEBUG_LEVEL=2 -fsanitize=address")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstandalone-debug")
endif()
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address")
endif()
file(READ "VERSION" VERSION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION=${VERSION}")
###############################################################################
## file globbing ##############################################################
###############################################################################
# these instructions search the directory tree when cmake is
# invoked and put all files that match the pattern in the variables
# `sources` and `data`
if(WIN32)
set(uxs_platform_dir uxs/platform/win)
elseif(UNIX)
set(uxs_platform_dir uxs/platform/posix)
endif()
file(GLOB_RECURSE includes include/*.h)
file(GLOB_RECURSE sources src/*.h;src/*.cpp)
file(GLOB_RECURSE uxs_includes uxs/include/*.h)
file(GLOB_RECURSE uxs_sources uxs/src/*.h;uxs/src/*.cpp)
file(GLOB_RECURSE uxs_platform_sources ${uxs_platform_dir}/src/*.h;${uxs_platform_dir}/src/*.cpp)
# you can use set(sources src/main.cpp) etc if you don't want to
# use globing to find files automatically
###############################################################################
## target definitions #########################################################
###############################################################################
# add the data to the target, so it becomes visible in some IDE
add_executable(parsegen
.clang-format
${uxs_includes}
${uxs_sources}
${uxs_platform_sources}
${includes}
${sources}
)
# link with these libraries
if(MSVC)
else()
target_link_libraries(parsegen stdc++ m)
endif()
# this lets me include files relative to the root src dir with a <> pair
target_include_directories(parsegen PUBLIC uxs/include include)