Skip to content

Commit 9328a70

Browse files
committed
upgrade cmake/ scripts
1 parent ef92415 commit 9328a70

37 files changed

+3769
-1642
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ docs/manual/
2020

2121
*.local.cmake
2222
*.code-workspace
23+
.build-serial
2324

2425
/_*
2526

CMakeLists.txt

+53-19
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,67 @@
11
# # TPL ## HEAD ##########
22
cmake_minimum_required(VERSION 3.11)
3-
set(CMAKE_SCRIPTS "cmake")
4-
set(CMAKE_MODULE_PATH
5-
${CMAKE_SOURCE_DIR}/addons
6-
${CMAKE_SOURCE_DIR}/${CMAKE_SCRIPTS}/modules
7-
${CMAKE_SOURCE_DIR}/${CMAKE_SCRIPTS}
8-
${CMAKE_SOURCE_DIR} # for .version.cmake & .options.cmake
9-
${CMAKE_MODULE_PATH})
10-
include(prerequisites)
11-
12-
# include(dummy-project)
3+
4+
# ### INCLUDES ##########################################################
5+
include(${CMAKE_SOURCE_DIR}/cmake/prerequisites.cmake)
6+
7+
# use_vcpkg()
8+
9+
# ### DEFINITIONS #######################################################
10+
set(PROJECT_MACRO_NAME cmdr-cxx)
11+
set(PROJECT_MACRO_SHORT_NAME cmdr)
12+
set(PROJECT_MACRO_MID_NAME cmdr11)
13+
set(PROJECT_MACRO_PREFIX "CMDR")
14+
set_property(GLOBAL PROPERTY PROJECT_MAINTAINER "hedzr <[email protected]>")
15+
16+
# ### OPTIONS ###########################################################
17+
18+
# option(OK "PL-OK" ON)
19+
20+
# option(${PROJECT_MACRO_PREFIX}_BUILD_TESTS_EXAMPLES "Build Test Examples OK" OFF)
21+
# option(${PROJECT_MACRO_PREFIX}_BUILD_DOCS "Build Docs-OK" OFF)
22+
23+
# the following options are just used for executables
24+
option(${PROJECT_MACRO_PREFIX}_ENABLE_ASSERTIONS "Enable Assertions" OFF)
25+
option(${PROJECT_MACRO_PREFIX}_ENABLE_PRECONDITION_CHECKS "Enable Precondition Checks" OFF)
26+
option(${PROJECT_MACRO_PREFIX}_ENABLE_THREAD_POOL_READY_SIGNAL "Enable ready signal actions in thread_pool template class" OFF)
27+
option(${PROJECT_MACRO_PREFIX}_ENABLE_VERBOSE_LOG "Enable `dbg_verbose_debug` macro definition (TRACE MODE)" OFF)
28+
option(${PROJECT_MACRO_PREFIX}_TEST_THREAD_POOL_DBGOUT "Enable `pool_debug` macro definition" OFF)
29+
option(${PROJECT_MACRO_PREFIX}_UNIT_TEST "Enable the extra unit-tests" OFF)
30+
31+
32+
# ### PROJECTS PREPARE ##################################################
33+
if(ENABLE_TESTS)
34+
include(CTest)
35+
endif()
36+
37+
find_package(Threads REQUIRED)
38+
39+
# ### PROJECTS ##########################################################
1340
project(cmdr-cxx
1441
VERSION ${VERSION}
1542
DESCRIPTION "cmdr-cxx is a POSIX-compliant command-line arguments parser in C++, its part of cmdr series."
1643
LANGUAGES CXX)
44+
debug_print_project_title()
1745

1846
set(VERSION_H_NAME "cmdr-version.hh")
1947

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

24-
debug_print_top_vars()
53+
# if(ENABLE_TESTS)
54+
# include(load-catch2)
55+
# endif()
2556

26-
# # TPL ## HEAD END ##########
27-
set(PROJECT_MACRO_NAME cmdr-cxx)
28-
set(PROJECT_MACRO_SHORT_NAME cmdr)
29-
set(PROJECT_MACRO_MID_NAME cmdr11)
30-
set(PROJECT_MACRO_PREFIX "CMDR")
57+
# # when using compiler with cmake multi-config feature, a special build type 'Asan' can be used for sanitizing test.
58+
# enable_sanitizer_for_multi_config()
59+
60+
# # include(cxx-standard-def)
61+
# include(cxx-detect-compilers)
62+
# include(setup-build-env)
63+
64+
# debug_print_top_vars()
3165

3266
gen_versions(${PROJECT_MACRO_NAME} ${PROJECT_MACRO_PREFIX}
3367
${PROJECT_MACRO_SHORT_NAME}-version.hh

cmake/Modules/FindSomething.cmake

-1
This file was deleted.

cmake/Modules/FindXXX.cmake

Whitespace-only changes.

cmake/add-policies.cmake

+25-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Set policies
32
# https://www.mankier.com/7/cmake-policies
43

@@ -7,77 +6,77 @@
76
# entries. Run "cmake --help-policy CMP0049" for policy details. Use the
87
# cmake_policy command to set the policy and suppress this warning.
98
if (POLICY CMP0049)
10-
cmake_policy(SET CMP0049 NEW)
9+
cmake_policy(SET CMP0049 NEW)
1110
endif ()
1211

1312
if (COMMAND cmake_policy)
14-
# we prefer the more strict behavior, to find out more:
15-
# cmake --help-policy CMP0003
16-
cmake_policy(SET CMP0003 NEW)
13+
# we prefer the more strict behavior, to find out more:
14+
# cmake --help-policy CMP0003
15+
cmake_policy(SET CMP0003 NEW)
1716
endif ()
1817

19-
2018
# Compiler id for Apple Clang is now AppleClang.
2119
if (POLICY CMP0025)
22-
cmake_policy(SET CMP0025 NEW)
20+
cmake_policy(SET CMP0025 NEW)
2321
endif (POLICY CMP0025)
2422

2523
# MACOSX_RPATH is enabled by default.
2624
if (POLICY CMP0042)
27-
cmake_policy(SET CMP0042 NEW)
28-
endif ()
29-
if (POLICY CMP0048)
30-
cmake_policy(SET CMP0048 NEW)
25+
cmake_policy(SET CMP0042 NEW)
3126
endif ()
3227

3328
# Project version variables are the empty string if version is unspecified
3429
if (POLICY CMP0048)
35-
cmake_policy(SET CMP0048 NEW)
30+
cmake_policy(SET CMP0048 NEW)
3631
endif (POLICY CMP0048)
3732

3833
# Only interpret if() arguments as variables or keywords when unquoted.
3934
if (POLICY CMP0054)
40-
cmake_policy(SET CMP0054 NEW)
35+
cmake_policy(SET CMP0054 NEW)
4136
endif ()
4237

4338
# if command can use IN_LIST
4439
if (POLICY CMP0057)
45-
cmake_policy(SET CMP0057 NEW)
40+
cmake_policy(SET CMP0057 NEW)
4641
endif (POLICY CMP0057)
4742

4843
# Honor visibility properties for all target types.
4944
if (POLICY CMP0063)
50-
cmake_policy(SET CMP0063 NEW)
45+
cmake_policy(SET CMP0063 NEW)
5146
endif ()
5247

5348
if (POLICY CMP0068)
54-
cmake_policy(SET CMP0068 NEW)
49+
cmake_policy(SET CMP0068 NEW)
5550
endif ()
5651

5752
if (POLICY CMP0069)
58-
cmake_policy(SET CMP0069 NEW)
53+
cmake_policy(SET CMP0069 NEW)
5954
endif ()
6055

61-
#if (POLICY CMP0070)
62-
#cmake_policy(SET CMP0070 NEW)
63-
#endif ()
64-
56+
# if (POLICY CMP0070)
57+
# cmake_policy(SET CMP0070 NEW)
58+
# endif ()
6559
if (POLICY CMP0076)
66-
cmake_policy(SET CMP0076 NEW) # target_sources() command converts relative paths to absolute
60+
cmake_policy(SET CMP0076 NEW) # target_sources() command converts relative paths to absolute
6761
endif ()
6862

6963
# option() honors normal variables
7064
if (POLICY CMP0077)
71-
cmake_policy(SET CMP0077 NEW)
65+
cmake_policy(SET CMP0077 NEW)
7266
endif (POLICY CMP0077)
7367

68+
# if (POLICY CMP0086)
69+
# # UseSWIG honors SWIG_MODULE_NAME via -module flag
70+
# cmake_policy(SET CMP0086 NEW)
71+
# endif ()
72+
7473
# Allow the user to specify the MSVC runtime
7574
if (POLICY CMP0091)
76-
cmake_policy(SET CMP0091 NEW)
75+
cmake_policy(SET CMP0091 NEW)
7776
endif (POLICY CMP0091)
7877

7978
if (POLICY CMP0120)
80-
cmake_policy(SET CMP0120 NEW) # The WriteCompilerDetectionHeader module is removed
79+
cmake_policy(SET CMP0120 NEW) # The WriteCompilerDetectionHeader module is removed
8180
endif ()
8281

8382
if (POLICY CMP0068)
@@ -86,5 +85,5 @@ endif ()
8685

8786

8887
if ("${CMAKE_VERSION}" VERSION_LESS "3.12")
89-
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
88+
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
9089
endif ()

0 commit comments

Comments
 (0)