-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
73 lines (63 loc) · 2.49 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
cmake_minimum_required(VERSION 3.13.4)
set( PRJ_NAME "min_header" )
project( ${PRJ_NAME} )
# src
add_subdirectory(src)
set_property( TARGET ${PRJ_NAME} PROPERTY FOLDER ${PRJ_NAME} )
set_property( TARGET ${PRJ_NAME} PROPERTY CXX_STANDARD 20 )
target_precompile_headers( ${PRJ_NAME} PRIVATE src/stdafx.h )
# static lib
if( 0 )
if( MSVC )
set( CMAKE_FIND_LIBRARY_SUFFIXES ".lib" )
target_compile_options( ${PRJ_NAME} PRIVATE /MT )
target_link_options( ${PRJ_NAME} PRIVATE /INCREMENTAL:NO /NODEFAULTLIB:MSVCRT )
#set( CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
else()
set( CMAKE_FIND_LIBRARY_SUFFIXES ".a" )
set( BUILD_SHARED_LIBS OFF )
target_link_libraries( ${PRJ_NAME} PRIVATE -static )
endif()
endif()
# clang
set( SUPPORTS_BREPRO OFF ) # avoid warning
#find_package( LLVM CONFIG REQUIRED )
find_package( Clang CONFIG REQUIRED )
include( HandleLLVMOptions )
message( "LLVM_DEFINITIONS: ${LLVM_DEFINITIONS}" )
target_compile_definitions( ${PRJ_NAME} PRIVATE ${LLVM_DEFINITIONS} )
list( APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}" )
target_include_directories( ${PRJ_NAME} PRIVATE ${LLVM_INCLUDE_DIRS} )
if( 0 )
execute_process( COMMAND llvm-config --components OUTPUT_VARIABLE llvm_comp OUTPUT_STRIP_TRAILING_WHITESPACE )
string(REPLACE " " ";" llvm_comp ${llvm_comp})
message( "llvm_comp='${llvm_comp}'/n" )
llvm_map_components_to_libnames( llvm_libs ${llvm_comp} )
list( REMOVE_ITEM llvm_libs LLVMWindowsManifest LLVMall-targets LLVMjit LLVMx86 )
message( "llvm_libs='${llvm_libs}'" )
target_link_libraries( ${PRJ_NAME} PRIVATE ${llvm_libs} )
else()
target_link_libraries(${PRJ_NAME} PRIVATE
clangAST
clangBasic
clangDriver
clangFrontend
clangRewriteFrontend
clangSerialization
clangStaticAnalyzerFrontend
clangTooling
clangToolingSyntax
)
endif()
# boost
find_package( Boost REQUIRED COMPONENTS thread serialization )
if(Boost_FOUND)
message( "Boost found: ${Boost_INCLUDE_DIRS}" )
target_include_directories( ${PRJ_NAME} PRIVATE ${Boost_INCLUDE_DIRS} )
target_link_libraries( ${PRJ_NAME} PRIVATE ${Boost_LIBRARIES} )
endif()
# VS properties
if( MSVC )
set_property( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PRJ_NAME} )
set_property( TARGET ${PRJ_NAME} PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS --help )
endif()