aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-07-03 22:52:23 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-07-04 00:11:46 +0200
commit7fdde689caa9f241c90dbf2acc02c954c7d616e4 (patch)
tree4faf50fcee17e4df69f476a775b4c7aab2bb5884
parentcommon.cmake: bump default C++ standard (diff)
downloadcmake-common-7fdde689caa9f241c90dbf2acc02c954c7d616e4.tar.gz
cmake-common-7fdde689caa9f241c90dbf2acc02c954c7d616e4.zip
common.cmake: refactoring
-rw-r--r--common.cmake36
1 files changed, 18 insertions, 18 deletions
diff --git a/common.cmake b/common.cmake
index 619b062..8ab0686 100644
--- a/common.cmake
+++ b/common.cmake
@@ -56,11 +56,11 @@ endif()
if(NOT DEFINED CC_CXX_STANDARD)
set(CC_CXX_STANDARD "20" CACHE STRING "C++ standard version")
endif()
-if(NOT DEFINED CC_BEST_PRACTICES)
- option(CC_BEST_PRACTICES "Set common compiler options" "${default_value}")
+if(NOT DEFINED CC_COMMON_OPTIONS)
+ option(CC_COMMON_OPTIONS "Set common compiler options" "${default_value}")
endif()
-if(NOT DEFINED CC_WINDOWS_DEF)
- option(CC_WINDOWS_DEF "Define useful Windows macros" "${default_value}")
+if(NOT DEFINED CC_WINDOWS_DEFINES)
+ option(CC_WINDOWS_DEFINES "Use common Windows macros" "${default_value}")
endif()
if(NOT DEFINED CC_STATIC_RUNTIME)
set(static_runtime_default_value "${default_value}")
@@ -80,8 +80,8 @@ option(Boost_USE_STATIC_RUNTIME "Use Boost libraries linked to the runtime stati
if(NOT parent_dir)
message(STATUS "common.cmake: Toolset: ${toolset}")
message(STATUS "common.cmake: C++ standard: ${CC_CXX_STANDARD}")
- message(STATUS "common.cmake: Common compiler options: ${CC_BEST_PRACTICES}")
- message(STATUS "common.cmake: Useful Windows macros: ${CC_WINDOWS_DEF}")
+ message(STATUS "common.cmake: Common compiler options: ${CC_COMMON_OPTIONS}")
+ message(STATUS "common.cmake: Common Windows defines: ${CC_WINDOWS_DEFINES}")
message(STATUS "common.cmake: Static Boost libraries: ${Boost_USE_STATIC_LIBS}")
message(STATUS "common.cmake: Static runtime: ${CC_STATIC_RUNTIME}")
message(STATUS "common.cmake: Strip symbols: ${CC_STRIP_SYMBOLS}")
@@ -97,25 +97,25 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# Common compiler options
# -----------------------
-function(_cc_best_practices_msvc target)
+function(_cc_common_options_msvc target)
set(compile_options /MP /W4)
target_compile_options("${target}" PRIVATE ${compile_options})
endfunction()
-function(_cc_best_practices_gcc target)
+function(_cc_common_options_gcc target)
set(compile_options -Wall -Wextra)
target_compile_options("${target}" PRIVATE ${compile_options})
endfunction()
-function(_cc_best_practices target)
+function(_cc_common_options target)
get_target_property(target_type "${target}" TYPE)
get_target_property(aliased "${target}" ALIASED_TARGET)
if(NOT target_type STREQUAL "INTERFACE_LIBRARY" AND NOT aliased)
message(STATUS "common.cmake: ${target}: Setting common compiler options")
if(is_msvc)
- _cc_best_practices_msvc("${target}")
+ _cc_common_options_msvc("${target}")
elseif(is_gcc OR is_clang)
- _cc_best_practices_gcc("${target}")
+ _cc_common_options_gcc("${target}")
endif()
endif()
endfunction()
@@ -123,16 +123,16 @@ endfunction()
# Useful Windows macros
# ---------------------
-function(_cc_common_windows_definitions target)
+function(_cc_common_windows_defines target)
set(compile_definitions WIN32_LEAN_AND_MEAN NOMINMAX)
get_target_property(target_type "${target}" TYPE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
- message(STATUS "common.cmake: ${target}: Defining useful Windows macros")
+ message(STATUS "common.cmake: ${target}: Using common Windows defines")
target_compile_definitions("${target}" INTERFACE ${compile_definitions})
else()
get_target_property(aliased "${target}" ALIASED_TARGET)
if(NOT aliased)
- message(STATUS "common.cmake: ${target}: Defining useful Windows macros")
+ message(STATUS "common.cmake: ${target}: Using common Windows defines")
target_compile_definitions("${target}" PRIVATE ${compile_definitions})
endif()
endif()
@@ -301,11 +301,11 @@ function(_cc_apply_settings target)
if(TARGET "${target}")
get_target_property(target_imported "${target}" IMPORTED)
if(NOT target_imported)
- if(CC_BEST_PRACTICES)
- _cc_best_practices("${target}")
+ if(CC_COMMON_OPTIONS)
+ _cc_common_options("${target}")
endif()
- if(CC_WINDOWS_DEF)
- _cc_common_windows_definitions("${target}")
+ if(CC_WINDOWS_DEFINES)
+ _cc_common_windows_defines("${target}")
endif()
if(CC_STRIP_SYMBOLS)
_cc_strip_symbols("${target}")