-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
52 lines (36 loc) · 1.46 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
cmake_minimum_required(VERSION 3.2)
project(layout)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
set(CLANG_LIBS clang)
find_package(LLVM REQUIRED)
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
include_directories(SYSTEM ${CLANG_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
set(CMAKE_EXE_LINKER_FLAGS ${LLVM_LD_FLAGS_STRING})
set(CXX_STANDARD_REQUIRED ON)
set(CPP_FLAGS -std=c++17 -fno-rtti)
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -DENABLE_FAKING")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_EXE_LINKER_FLAGS "-flto")
endif()
add_compile_options(${CPP_FLAGS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_subdirectory(src)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
message(STATUS "Binaries will land in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
add_executable(layout exe/main.cpp)
target_link_libraries(layout layoutlib ${CLANG_LIBS})
file(GLOB LAYOUT_TEST_SOURCES test/*.cpp)
add_compile_options("-fexceptions")
add_executable(layout_test ${LAYOUT_TEST_SOURCES})
set(TEST_ADDITIONAL_LIBRARIES stdc++fs)
target_link_libraries(layout_test layoutlib ${CLANG_LIBS}
${TEST_ADDITIONAL_LIBRARIES})
add_custom_command(TARGET layout POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_SOURCE_DIR}/compile_commands.json)