Set CMake C & C++ standard per target
authorCharles Giessen <charles@lunarg.com>
Thu, 17 Feb 2022 05:01:44 +0000 (22:01 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Wed, 9 Mar 2022 22:06:30 +0000 (15:06 -0700)
CMakeLists.txt
loader/CMakeLists.txt
tests/framework/CMakeLists.txt

index 665c8588b29f77fb306e02d0a27920605ef2ec1b..ccfb2e27a50f2d1a7d7347dfa8d4744afcb541be 100644 (file)
@@ -259,6 +259,9 @@ target_link_libraries(loader_common_options INTERFACE platform_wsi_defines)
 # Enable beta Vulkan extensions
 target_compile_definitions(loader_common_options INTERFACE VK_ENABLE_BETA_EXTENSIONS)
 
+target_compile_features(loader_common_options INTERFACE c_std_99)
+target_compile_features(loader_common_options INTERFACE cxx_std_11)
+
 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
     target_compile_options(loader_common_options INTERFACE -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -fno-builtin-memcmp)
 
@@ -299,8 +302,7 @@ if(MSVC)
     # /w34057: Warn about different indirection types.
     # /w34245: Warn about signed/unsigned mismatch.
     # /guard:cf: Enable control flow guard
-    # /permissive-: Use standard conformance mode
-    target_compile_options(loader_common_options INTERFACE /WX /GR- /w34456 /w34701 /w34703 /w34057 /w34245 /guard:cf /permissive-)
+    target_compile_options(loader_common_options INTERFACE /WX /GR- /w34456 /w34701 /w34703 /w34057 /w34245 /guard:cf)
 
     # Enable control flow guard
     list(APPEND CMAKE_SHARED_LINKER_FLAGS /guard:cf)
index 34e02ba3a94e1b0373b3eee591b79be4185e000d..f748ff3297afa478a17da7a1c44c355b3d653d7f 100644 (file)
@@ -330,16 +330,6 @@ endif()
 
 # common attributes of the vulkan library
 target_link_libraries(vulkan loader_specific_options)
-set_target_properties(vulkan PROPERTIES
-    C_STANDARD 99
-    C_STANDARD_REQUIRED YES
-    C_EXTENSIONS NO
-)
-set_target_properties(vulkan  PROPERTIES
-    CXX_STANDARD 11
-    CXX_STANDARD_REQUIRED YES
-    CXX_EXTENSIONS NO
-)
 
 # Generate pkg-config file.
 include(FindPkgConfig QUIET)
index 6328da03bb56bff4e91daf80e1c395109939249f..c47cd997dac46224e508b63994f746d2a22b0943 100644 (file)
@@ -15,8 +15,9 @@
 # limitations under the License.
 # ~~~
 
-add_library(testing_framework_util STATIC test_util.cpp test_util.h)
+add_library(testing_framework_util STATIC test_util.cpp)
 target_link_libraries(testing_framework_util PUBLIC Vulkan::Headers loader_common_options platform_wsi_defines)
+
 if(UNIX OR APPLE)
     target_link_libraries(testing_framework_util PUBLIC ${CMAKE_DL_LIBS})
 endif()