Skip to content

Commit ba91e3f

Browse files
committed
compile_features language std to avoid needless flags and warnings
1 parent 3f10136 commit ba91e3f

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,4 @@ include(CTest)
88

99
include (cmake/compilers.cmake)
1010

11-
set(CMAKE_C_STANDARD 99)
12-
set(CMAKE_CXX_STANDARD 11)
13-
1411
add_subdirectory(src)

src/c/CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ set_target_properties(c_fortran_struct PROPERTIES LINKER_LANGUAGE C)
2929
target_compile_definitions(c_fortran_struct PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
3030
add_test(NAME C_Fortran_struct COMMAND c_fortran_struct)
3131

32-
set_tests_properties(
33-
C_Fortran_error C_Fortran_struct C_Fortran_submodule
34-
PROPERTIES
35-
TIMEOUT 5
36-
)
32+
# --- props
33+
34+
get_property(targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
35+
36+
foreach(t IN LISTS targets)
37+
target_compile_features(${t} PRIVATE c_std_99)
38+
endforeach()
39+
40+
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
41+
42+
set_tests_properties(${test_names} PROPERTIES TIMEOUT 5)

src/cxx/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ set_target_properties(cxx_fortran_struct PROPERTIES LINKER_LANGUAGE CXX)
5454
target_compile_definitions(cxx_fortran_struct PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
5555
add_test(NAME C++_Fortran_struct COMMAND cxx_fortran_struct)
5656

57+
# --- props
5758

58-
set_tests_properties(
59-
C++_Fortran_array C++_Fortran_vector C++_Fortran_error C++_Fortran_struct C++_Fortran_submodule
60-
PROPERTIES
61-
TIMEOUT 5
62-
)
59+
get_property(targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
60+
61+
foreach(t IN LISTS targets)
62+
target_compile_features(${t} PRIVATE cxx_std_11)
63+
endforeach()
64+
65+
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
66+
67+
set_tests_properties(${test_names} PROPERTIES TIMEOUT 5)

src/fortran/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ add_test(NAME Fortran_C_error
5151
COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:fortran_c_error> -Dexp_code=42 -P ${PROJECT_SOURCE_DIR}/cmake/test_error.cmake
5252
)
5353

54-
set_tests_properties(
55-
Fortran_C_vector Fortran_C_struct Fortran_C_error
56-
Fortran_C++_vector Fortran_C++_struct Fortran_C++_error
57-
PROPERTIES
58-
TIMEOUT 5
59-
)
54+
# --- props
55+
56+
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
57+
58+
set_tests_properties(${test_names} PROPERTIES TIMEOUT 5)

0 commit comments

Comments
 (0)