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 55cmake_minimum_required (VERSION 3.11)
66project (cppast VERSION 0.1.0)
77
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+
814# options
915option (CPPAST_BUILD_TEST "whether or not to build the tests" OFF )
1016option (CPPAST_BUILD_EXAMPLE "whether or not to build the examples" OFF )
1117option (CPPAST_BUILD_TOOL "whether or not to build the tool" OFF )
1218
13- if (${CPPAST_BUILD_TEST} OR ( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR ) )
19+ if (${CPPAST_BUILD_TEST} OR ${is_top_level_project} )
1420 set (build_test ON )
1521 set (CMAKE_EXPORT_COMPILE_COMMANDS ON ) # for the self integration test
1622else ()
1723 set (build_test OFF )
1824endif ()
1925
20- if (${CPPAST_BUILD_EXAMPLE} OR ( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR ) )
26+ if (${CPPAST_BUILD_EXAMPLE} OR ${is_top_level_project} )
2127 set (build_example ON )
2228else ()
2329 set (build_example OFF )
2430endif ()
2531
26- if (${CPPAST_BUILD_TOOL} OR ( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR ) )
32+ if (${CPPAST_BUILD_TOOL} OR ${is_top_level_project} )
2733 set (build_tool ON )
2834else ()
2935 set (build_tool OFF )
Original file line number Diff line number Diff line change @@ -113,15 +113,18 @@ target_compile_definitions(cppast PUBLIC
113113 CPPAST_VERSION_MINOR="${cppast_VERSION_MINOR} "
114114 CPPAST_VERSION_MAJOR="${cppast_VERSION_MAJOR} "
115115 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 ()
125128
126129install (TARGETS cppast)
127130install (DIRECTORY ../include / DESTINATION include )
You can’t perform that action at this time.
0 commit comments