Skip to content

Commit

Permalink
Always use same method to set language version.
Browse files Browse the repository at this point in the history
That method is target_compile_features.
  • Loading branch information
MarkCallow committed Sep 14, 2024
1 parent dda210d commit 8347a30
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 54 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,6 @@ macro(common_libktx_settings target enable_write library_type)
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES"
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES

)
if(APPLE_LOCKED_OS)
set_target_properties(${target} PROPERTIES
Expand Down Expand Up @@ -1094,6 +1091,11 @@ target_include_directories(
PUBLIC
utils
)
target_compile_features(
objUtil
PUBLIC
cxx_std_11
)

# In C++ apps that use statically linked Libraries all compilatiom units must
# be compiled with matching symbol visibility settings to avoid warnings from
Expand Down
7 changes: 3 additions & 4 deletions tests/ktxdiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ add_executable(ktxdiff
ktxdiff_main.cpp
)

set_target_properties(
target_compile_features(
ktxdiff
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
PUBLIC
cxx_std_17
)

target_include_directories(
Expand Down
13 changes: 6 additions & 7 deletions tests/streamtests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ add_executable( streamtests
set_test_properties(streamtests)
set_code_sign(streamtests)

target_compile_features(
streamtests
PUBLIC
# C++14 for std::make_unique on AppleClang and Linux GCC
cxx_std_14
)
target_include_directories(
streamtests
PRIVATE
Expand All @@ -15,13 +21,6 @@ PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../lib # Just for gl_format.h
)

set_target_properties(
streamtests PROPERTIES
# Force C++14 (for std::make_unique on AppleClang and Linux GCC)
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
)

target_link_libraries(
streamtests
gtest
Expand Down
13 changes: 6 additions & 7 deletions tests/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ add_executable( unittests
set_test_properties(unittests)
set_code_sign(unittests)

target_compile_features(
unittests
PUBLIC
cxx_std_17
)

target_include_directories(
unittests
PRIVATE
Expand All @@ -68,13 +74,6 @@ target_link_libraries(
${CMAKE_THREAD_LIBS_INIT}
)

set_target_properties(
unittests
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)

add_executable( texturetests
texturetests/texturetests.cc
unittests/wthelper.h
Expand Down
7 changes: 4 additions & 3 deletions tools/imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ PRIVATE
$<TARGET_PROPERTY:ktx,INTERFACE_COMPILE_DEFINITIONS>
)

target_compile_features(imageio PUBLIC cxx_std_17)

target_link_libraries(imageio fmt::fmt)

set_target_properties(imageio PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_VISIBILITY_PRESET ${STATIC_APP_LIB_SYMBOL_VISIBILITY}
)

target_link_libraries(imageio fmt::fmt)
8 changes: 6 additions & 2 deletions tools/ktx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ set_target_properties(
PROPERTIES
OUTPUT_NAME ktx
PDB_NAME ktxtools # Avoid conflict with libktx's .pdb.
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)

target_include_directories(
Expand Down Expand Up @@ -77,5 +75,11 @@ PRIVATE
$<TARGET_PROPERTY:ktx,INTERFACE_COMPILE_DEFINITIONS>
)

target_compile_features(
ktxtools
PUBLIC
cxx_std_17
)

set_tool_properties(ktxtools)
set_code_sign(ktxtools)
20 changes: 12 additions & 8 deletions tools/ktx2check/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ add_executable( ktx2check
)
create_version_header( tools/ktx2check ktx2check )

set_target_properties(
ktx2check PROPERTIES
CXX_VISIBILITY_PRESET ${STATIC_APP_LIB_SYMBOL_VISIBILITY}
)

target_compile_features(
ktx2check
PUBLIC
# C++14 for std::make_unique on AppleClang and Linux GCC
cxx_std_14
)

target_include_directories(
ktx2check
PRIVATE
Expand All @@ -16,14 +28,6 @@ PRIVATE
${PROJECT_SOURCE_DIR}/other_include
)

set_target_properties(
ktx2check PROPERTIES
CXX_VISIBILITY_PRESET ${STATIC_APP_LIB_SYMBOL_VISIBILITY}
# Force C++14 (for std::make_unique on AppleClang and Linux GCC)
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
)

target_link_libraries(
ktx2check
ktx
Expand Down
13 changes: 6 additions & 7 deletions tools/ktxsc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ add_executable( ktxsc
)
create_version_header( tools/ktxsc ktxsc )

target_compile_features(
ktxsc
PUBLIC
cxx_std_17
)

target_include_directories(
ktxsc
PRIVATE
Expand All @@ -22,12 +28,5 @@ target_link_libraries(
objUtil
)

set_target_properties(
ktxsc
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)

set_tool_properties(ktxsc)
set_code_sign(ktxsc)
13 changes: 0 additions & 13 deletions tools/toktx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,12 @@ target_link_libraries(
objUtil
)

set_target_properties(
toktx
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)

target_compile_definitions(
toktx
PRIVATE
$<TARGET_PROPERTY:ktx,INTERFACE_COMPILE_DEFINITIONS>
)

# The tools, except ktx2check which explicitly chooses c++14, are somehow
# being set to use the c++11 dialect. Libraries and other targets are not.
# Despite searching every CMakeLists.txt and .cmake file in the project,
# I've been unable to find where this is being set. As toktx needs c++11
# (at least), explicitly set it here, a precaution against the mysterious
# setting disappearing.
target_compile_features(toktx PUBLIC cxx_std_11)

set_tool_properties(toktx)
Expand Down

0 comments on commit 8347a30

Please sign in to comment.