File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change 5
5
cmake_minimum_required (VERSION 3.11 )
6
6
project (cppast VERSION 0.1.0 )
7
7
8
+ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
9
+ set (is_top_level_project TRUE )
10
+ else ()
11
+ set (is_top_level_project FALSE )
12
+ endif ()
13
+
8
14
# options
9
15
option (CPPAST_BUILD_TEST "whether or not to build the tests" OFF )
10
16
option (CPPAST_BUILD_EXAMPLE "whether or not to build the examples" OFF )
11
17
option (CPPAST_BUILD_TOOL "whether or not to build the tool" OFF )
12
18
13
- if (${CPPAST_BUILD_TEST} OR ( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR ) )
19
+ if (${CPPAST_BUILD_TEST} OR ${is_top_level_project} )
14
20
set (build_test ON )
15
21
set (CMAKE_EXPORT_COMPILE_COMMANDS ON ) # for the self integration test
16
22
else ()
17
23
set (build_test OFF )
18
24
endif ()
19
25
20
- if (${CPPAST_BUILD_EXAMPLE} OR ( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR ) )
26
+ if (${CPPAST_BUILD_EXAMPLE} OR ${is_top_level_project} )
21
27
set (build_example ON )
22
28
else ()
23
29
set (build_example OFF )
24
30
endif ()
25
31
26
- if (${CPPAST_BUILD_TOOL} OR ( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR ) )
32
+ if (${CPPAST_BUILD_TOOL} OR ${is_top_level_project} )
27
33
set (build_tool ON )
28
34
else ()
29
35
set (build_tool OFF )
Original file line number Diff line number Diff line change @@ -113,15 +113,18 @@ target_compile_definitions(cppast PUBLIC
113
113
CPPAST_VERSION_MINOR= "${cppast_VERSION_MINOR} "
114
114
CPPAST_VERSION_MAJOR= "${cppast_VERSION_MAJOR} "
115
115
CPPAST_VERSION_STRING= "${cppast_VERSION} " )
116
- target_compile_options (cppast PRIVATE
117
- # clang/GCC warnings
118
- $< $< OR:$< CXX_COMPILER_ID:Clang> ,$< CXX_COMPILER_ID:GNU> > :
119
- -pedantic-errors -Werror -Wall -Wextra -Wconversion -Wsign-conversion>
120
- # disable noexcept type warning on GCC
121
- $< $< CXX_COMPILER_ID:GNU> : -Wno-noexcept-type>
122
- # MSVC warnings
123
- $< $< CXX_COMPILER_ID:MSVC> :
124
- /W3> )
116
+
117
+ if (${is_top_level_project} )
118
+ target_compile_options (cppast PRIVATE
119
+ # clang/GCC warnings
120
+ $< $< OR:$< CXX_COMPILER_ID:Clang> ,$< CXX_COMPILER_ID:GNU> > :
121
+ -pedantic-errors -Werror -Wall -Wextra -Wconversion -Wsign-conversion>
122
+ # disable noexcept type warning on GCC
123
+ $< $< CXX_COMPILER_ID:GNU> : -Wno-noexcept-type>
124
+ # MSVC warnings
125
+ $< $< CXX_COMPILER_ID:MSVC> :
126
+ /W3> )
127
+ endif ()
125
128
126
129
install (TARGETS cppast )
127
130
install (DIRECTORY ../include/ DESTINATION include )
You can’t perform that action at this time.
0 commit comments