Set CMake properties consistently
authorJuan Ramos <juan@lunarg.com>
Fri, 29 Dec 2023 17:27:24 +0000 (10:27 -0700)
committerJuan Ramos <114601453+juan-lunarg@users.noreply.github.com>
Fri, 29 Dec 2023 18:39:10 +0000 (11:39 -0700)
Simplifies the code

Idiomatic way of setting visibility via CMake

CMakeLists.txt
loader/CMakeLists.txt

index 9dcd273c50857095e23d17138b625fbcc2eded7a..3618446aed7076e2d108f0438430c924f7ea5ed3 100644 (file)
@@ -20,6 +20,12 @@ project(VULKAN_LOADER VERSION 1.3.274 LANGUAGES C)
 
 add_subdirectory(scripts)
 
+set(CMAKE_C_STANDARD 99)
+set(CMAKE_C_STANDARD_REQUIRED ON)
+set(CMAKE_C_EXTENSIONS OFF)
+set(CMAKE_C_VISIBILITY_PRESET "hidden")
+set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+
 # By default, loader & tests are built without sanitizers
 # Use these options to force a specific sanitizer on the loader and test executables
 if (UNIX)
@@ -129,12 +135,6 @@ target_link_libraries(loader_common_options INTERFACE platform_wsi)
 # 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)
-set(LOADER_STANDARD_C_PROPERTIES C_STANDARD 99 C_STANDARD_REQUIRED YES C_EXTENSIONS OFF)
-
-# Force the use of the multithreaded, static version of the C runtime.
-set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
-
 option(BUILD_WERROR "Enable warnings as errors")
 
 # Set warnings as errors and the main diagnostic flags
@@ -163,10 +163,6 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
         endif()
     endif()
 
-    if(UNIX)
-        target_compile_options(loader_common_options INTERFACE -fvisibility=hidden)
-    endif()
-
     target_compile_options(loader_common_options INTERFACE -Wpointer-arith)
 endif()
 
index 784f443a74786523bd4394f6d8995dacbc3392cb..f495761ee5f90f5acbef4140326fb8e82b856f07 100644 (file)
@@ -460,11 +460,6 @@ endif()
 # common attributes of the vulkan library
 target_link_libraries(vulkan PRIVATE loader_specific_options)
 
-set_target_properties(vulkan PROPERTIES ${LOADER_STANDARD_C_PROPERTIES})
-if (TARGET asm_offset)
-    set_target_properties(asm_offset PROPERTIES ${LOADER_STANDARD_C_PROPERTIES})
-endif()
-
 target_link_libraries(vulkan PRIVATE Vulkan::Headers)
 add_library(Vulkan::Loader ALIAS vulkan)