Skip to content

Commit

Permalink
upgrade cmake/ scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Dec 4, 2024
1 parent ef92415 commit 9328a70
Show file tree
Hide file tree
Showing 37 changed files with 3,769 additions and 1,642 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ docs/manual/

*.local.cmake
*.code-workspace
.build-serial

/_*

Expand Down
72 changes: 53 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,67 @@
# # TPL ## HEAD ##########
cmake_minimum_required(VERSION 3.11)
set(CMAKE_SCRIPTS "cmake")
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/addons
${CMAKE_SOURCE_DIR}/${CMAKE_SCRIPTS}/modules
${CMAKE_SOURCE_DIR}/${CMAKE_SCRIPTS}
${CMAKE_SOURCE_DIR} # for .version.cmake & .options.cmake
${CMAKE_MODULE_PATH})
include(prerequisites)

# include(dummy-project)

# ### INCLUDES ##########################################################
include(${CMAKE_SOURCE_DIR}/cmake/prerequisites.cmake)

# use_vcpkg()

# ### DEFINITIONS #######################################################
set(PROJECT_MACRO_NAME cmdr-cxx)
set(PROJECT_MACRO_SHORT_NAME cmdr)
set(PROJECT_MACRO_MID_NAME cmdr11)
set(PROJECT_MACRO_PREFIX "CMDR")
set_property(GLOBAL PROPERTY PROJECT_MAINTAINER "hedzr <hedzr@duck.com>")

# ### OPTIONS ###########################################################

# option(OK "PL-OK" ON)

# option(${PROJECT_MACRO_PREFIX}_BUILD_TESTS_EXAMPLES "Build Test Examples OK" OFF)
# option(${PROJECT_MACRO_PREFIX}_BUILD_DOCS "Build Docs-OK" OFF)

# the following options are just used for executables
option(${PROJECT_MACRO_PREFIX}_ENABLE_ASSERTIONS "Enable Assertions" OFF)
option(${PROJECT_MACRO_PREFIX}_ENABLE_PRECONDITION_CHECKS "Enable Precondition Checks" OFF)
option(${PROJECT_MACRO_PREFIX}_ENABLE_THREAD_POOL_READY_SIGNAL "Enable ready signal actions in thread_pool template class" OFF)
option(${PROJECT_MACRO_PREFIX}_ENABLE_VERBOSE_LOG "Enable `dbg_verbose_debug` macro definition (TRACE MODE)" OFF)
option(${PROJECT_MACRO_PREFIX}_TEST_THREAD_POOL_DBGOUT "Enable `pool_debug` macro definition" OFF)
option(${PROJECT_MACRO_PREFIX}_UNIT_TEST "Enable the extra unit-tests" OFF)


# ### PROJECTS PREPARE ##################################################
if(ENABLE_TESTS)
include(CTest)
endif()

find_package(Threads REQUIRED)

# ### PROJECTS ##########################################################
project(cmdr-cxx
VERSION ${VERSION}
DESCRIPTION "cmdr-cxx is a POSIX-compliant command-line arguments parser in C++, its part of cmdr series."
LANGUAGES CXX)
debug_print_project_title()

set(VERSION_H_NAME "cmdr-version.hh")

# include(cxx-standard-def)
include(cxx-detect-compilers)
include(setup-build-env)
# Enable C++ Standard 17/20 here. Change it on fist configuring, or update it with new value:
# cmake -S. -Bbuild -DCXX_STANDARD:STRING=20
set(CXX_STANDARD 17 CACHE STRING "Define The C++ Standard, default is 17")
enable_cxx_standard(CXX_STANDARD)

debug_print_top_vars()
# if(ENABLE_TESTS)
# include(load-catch2)
# endif()

# # TPL ## HEAD END ##########
set(PROJECT_MACRO_NAME cmdr-cxx)
set(PROJECT_MACRO_SHORT_NAME cmdr)
set(PROJECT_MACRO_MID_NAME cmdr11)
set(PROJECT_MACRO_PREFIX "CMDR")
# # when using compiler with cmake multi-config feature, a special build type 'Asan' can be used for sanitizing test.
# enable_sanitizer_for_multi_config()

# # include(cxx-standard-def)
# include(cxx-detect-compilers)
# include(setup-build-env)

# debug_print_top_vars()

gen_versions(${PROJECT_MACRO_NAME} ${PROJECT_MACRO_PREFIX}
${PROJECT_MACRO_SHORT_NAME}-version.hh
Expand Down
1 change: 0 additions & 1 deletion cmake/Modules/FindSomething.cmake

This file was deleted.

Empty file added cmake/Modules/FindXXX.cmake
Empty file.
51 changes: 25 additions & 26 deletions cmake/add-policies.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Set policies
# https://www.mankier.com/7/cmake-policies

Expand All @@ -7,77 +6,77 @@
# entries. Run "cmake --help-policy CMP0049" for policy details. Use the
# cmake_policy command to set the policy and suppress this warning.
if (POLICY CMP0049)
cmake_policy(SET CMP0049 NEW)
cmake_policy(SET CMP0049 NEW)
endif ()

if (COMMAND cmake_policy)
# we prefer the more strict behavior, to find out more:
# cmake --help-policy CMP0003
cmake_policy(SET CMP0003 NEW)
# we prefer the more strict behavior, to find out more:
# cmake --help-policy CMP0003
cmake_policy(SET CMP0003 NEW)
endif ()


# Compiler id for Apple Clang is now AppleClang.
if (POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
cmake_policy(SET CMP0025 NEW)
endif (POLICY CMP0025)

# MACOSX_RPATH is enabled by default.
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif ()
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0042 NEW)
endif ()

# Project version variables are the empty string if version is unspecified
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)

# Only interpret if() arguments as variables or keywords when unquoted.
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0054 NEW)
endif ()

# if command can use IN_LIST
if (POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
cmake_policy(SET CMP0057 NEW)
endif (POLICY CMP0057)

# Honor visibility properties for all target types.
if (POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
cmake_policy(SET CMP0063 NEW)
endif ()

if (POLICY CMP0068)
cmake_policy(SET CMP0068 NEW)
cmake_policy(SET CMP0068 NEW)
endif ()

if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
cmake_policy(SET CMP0069 NEW)
endif ()

#if (POLICY CMP0070)
#cmake_policy(SET CMP0070 NEW)
#endif ()

# if (POLICY CMP0070)
# cmake_policy(SET CMP0070 NEW)
# endif ()
if (POLICY CMP0076)
cmake_policy(SET CMP0076 NEW) # target_sources() command converts relative paths to absolute
cmake_policy(SET CMP0076 NEW) # target_sources() command converts relative paths to absolute
endif ()

# option() honors normal variables
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
cmake_policy(SET CMP0077 NEW)
endif (POLICY CMP0077)

# if (POLICY CMP0086)
# # UseSWIG honors SWIG_MODULE_NAME via -module flag
# cmake_policy(SET CMP0086 NEW)
# endif ()

# Allow the user to specify the MSVC runtime
if (POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0091 NEW)
endif (POLICY CMP0091)

if (POLICY CMP0120)
cmake_policy(SET CMP0120 NEW) # The WriteCompilerDetectionHeader module is removed
cmake_policy(SET CMP0120 NEW) # The WriteCompilerDetectionHeader module is removed
endif ()

if (POLICY CMP0068)
Expand All @@ -86,5 +85,5 @@ endif ()


if ("${CMAKE_VERSION}" VERSION_LESS "3.12")
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif ()
Loading

0 comments on commit 9328a70

Please sign in to comment.