Using target_compile_features to specify C++ 11 standard
This commit is contained in:
		
							parent
							
								
									d2dd27dc3b
								
							
						
					
					
						commit
						73cc5089e3
					
				
					 3 changed files with 9 additions and 8 deletions
				
			
		|  | @ -6,7 +6,7 @@ option(JSON_Coverage "Build test suite with coverage information" OFF) | |||
| if(JSON_Sanitizer) | ||||
|     message(STATUS "Building test suite with Clang sanitizer") | ||||
|     if(NOT MSVC) | ||||
|         set(CMAKE_CXX_FLAGS "-std=c++11 -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer") | ||||
|         set(CMAKE_CXX_FLAGS "-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer") | ||||
|     endif() | ||||
| endif() | ||||
| 
 | ||||
|  | @ -62,11 +62,10 @@ add_library(catch_main OBJECT | |||
|     "src/unit.cpp" | ||||
| ) | ||||
| set_target_properties(catch_main PROPERTIES | ||||
|     CXX_STANDARD 11 | ||||
|     CXX_STANDARD_REQUIRED ON | ||||
|     COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>" | ||||
|     COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>" | ||||
| ) | ||||
| target_compile_features(catch_main PUBLIC cxx_std_11) | ||||
| target_include_directories(catch_main PRIVATE "thirdparty/catch") | ||||
| 
 | ||||
| # https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake | ||||
|  | @ -96,13 +95,12 @@ foreach(file ${files}) | |||
| 
 | ||||
|     add_executable(${testcase} $<TARGET_OBJECTS:catch_main> ${file}) | ||||
|     set_target_properties(${testcase} PROPERTIES | ||||
|         CXX_STANDARD 11 | ||||
|         CXX_STANDARD_REQUIRED ON | ||||
|         COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>" | ||||
|         COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>" | ||||
|     ) | ||||
| 
 | ||||
|     target_compile_definitions(${testcase} PRIVATE CATCH_CONFIG_FAST_COMPILE) | ||||
|     target_compile_features(${testcase} PRIVATE cxx_std_11) | ||||
|     target_include_directories(${testcase} PRIVATE "thirdparty/catch") | ||||
|     target_include_directories(${testcase} PRIVATE "thirdparty/fifo_map") | ||||
|     target_include_directories(${testcase} PRIVATE ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue