Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wtudio committed Jul 14, 2023
1 parent 9e21679 commit 8a9bd29
Show file tree
Hide file tree
Showing 86 changed files with 931 additions and 839 deletions.
135 changes: 135 additions & 0 deletions .cmake-format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# ----------------------------------
# Options affecting listfile parsing
# ----------------------------------
with section("parse"):

# Specify structure for custom cmake functions
additional_commands = additional_commands = {
'FetchContent_Declare': {
'flags': ['OVERRIDE_FIND_PACKAGE'],
'kwargs': {
'URL': '*',
'URL_HASH': '*',
'DOWNLOAD_EXTRACT_TIMESTAMP': '*',
'GIT_REPOSITORY ': '*',
'GIT_TAG ': '*'
}
},
'add_protobuf_gencode_target_for_proto_path': {
'flags': [],
'kwargs': {
'TARGET_NAME': '*',
'PROTO_PATH': '*',
'GENCODE_PATH': '*',
'DEP_PROTO_TARGETS': '*',
'OPTIONS': '*'
}
},
'add_protobuf_gencode_target_for_one_proto_file': {
'flags': [],
'kwargs': {
'TARGET_NAME': '*',
'PROTO_FILE': '*',
'GENCODE_PATH': '*',
'DEP_PROTO_TARGETS': '*',
'OPTIONS': '*'
}
}
}

# Override configurations per-command where available
override_spec = {}

# Specify variable tags.
vartags = []

# Specify property tags.
proptags = []

# -----------------------------
# Options effecting formatting.
# -----------------------------
with section("format"):

# How wide to allow formatted cmake files
line_width = 150

# How many spaces to tab for indent
tab_size = 2

# If an argument group contains more than this many sub-groups (parg or kwarg
# groups) then force it to a vertical layout.
max_subgroups_hwrap = 2

# If a positional argument group contains more than this many arguments, then
# force it to a vertical layout.
max_pargs_hwrap = 6

# If a cmdline positional group consumes more than this many lines without
# nesting, then invalidate the layout (and nest)
max_rows_cmdline = 2

# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False

# If true, separate function names from parentheses with a space
separate_fn_name_with_space = False

# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on its own line.
dangle_parens = False

# A list of command names which should always be wrapped
always_wrap = ['target_link_libraries/PUBLIC/PargGroupNode[0]',
'target_link_libraries/PRIVATE/PargGroupNode[0]',
'target_link_libraries/INTERFACE/PargGroupNode[0]',
'target_include_directories/PUBLIC/PargGroupNode[0]',
'target_include_directories/PRIVATE/PargGroupNode[0]',
'target_include_directories/INTERFACE/PargGroupNode[0]',
'add_custom_target/DEPENDS/PargGroupNode[0]',
'add_protobuf_gencode_target_for_proto_path/DEP_PROTO_TARGETS/PargGroupNode[0]',
'add_protobuf_gencode_target_for_one_proto_file/DEP_PROTO_TARGETS/PargGroupNode[0]']

# ------------------------------------------------
# Options affecting comment reflow and formatting.
# ------------------------------------------------
with section("markup"):

# What character to use for bulleted lists
bullet_char = '*'

# What character to use as punctuation after numerals in an enumerated list
enum_char = '.'

# If comment markup is enabled, don't reflow the first comment block in each
# listfile. Use this to preserve formatting of your copyright/license
# statements.
first_comment_is_literal = False

# If comment markup is enabled, don't reflow any comment block which matches
# this (regex) pattern. Default is `None` (disabled).
literal_comment_pattern = None

# Regular expression to match preformat fences in comments default=
# ``r'^\s*([`~]{3}[`~]*)(.*)$'``
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'

# Regular expression to match rulers in comments default=
# ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'

# If a comment line matches starts with this pattern then it is explicitly a
# trailing comment for the preceeding argument. Default is '#<'
explicit_trailing_pattern = '#<'

# If a comment line starts with at least this many consecutive hash
# characters, then don't lstrip() them off. This allows for lazy hash rulers
# where the first hash char is not separated by space
hashruler_min_length = 10

# If true, then insert a space between the first hash char and remaining hash
# chars in a hash ruler, and normalize its length to fill the column
canonicalize_hashrulers = True

# enable comment markup parsing and reflow
enable_markup = False
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
build/
debug/
release/
gen/
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.26)

project(EasyFetchContentTestAll VERSION 0.1.0 LANGUAGES C CXX)
project(EasyFetchContentTestAll)

message(STATUS "uncomment to enable test for target library")

# NOTE: Do not test all at once. There may be conflicts between some libraries

# add_subdirectory(asio)
# add_subdirectory(boost)
# add_subdirectory(cjson)
Expand Down
25 changes: 10 additions & 15 deletions asio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.26)

set(PRJ_NAME "TestAsio")

project(${PRJ_NAME} VERSION 0.1.0 LANGUAGES C CXX)
project(${PRJ_NAME})
message(STATUS "start cmake ${PRJ_NAME} ...")

# enable c++20
Expand All @@ -14,9 +14,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(GetAsio)

# define head files and src files
File(GLOB hdrs ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
File(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
# define src files
file(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

# add target
add_executable(${PRJ_NAME})
Expand All @@ -25,15 +24,11 @@ add_executable(${PRJ_NAME})
target_sources(${PRJ_NAME} PRIVATE ${srcs})

# set head include path
target_include_directories(${PRJ_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(
${PRJ_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# set link target
target_link_libraries(${PRJ_NAME} PRIVATE
asio::asio
)

# set build definitions(if any)
# target_compile_definitions(${PRJ_NAME} PRIVATE xxx)

# set misc
set_property(TARGET ${PRJ_NAME} PROPERTY UNITY_BUILD ON)
target_link_libraries(
${PRJ_NAME}
PRIVATE asio::asio)
5 changes: 2 additions & 3 deletions asio/GetAsio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ message(STATUS "get asio ...")

FetchContent_Declare(
asio
URL https://github.com/chriskohlhoff/asio/archive/asio-1-21-0.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
URL https://github.com/chriskohlhoff/asio/archive/asio-1-21-0.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE)

FetchContent_GetProperties(asio)
if(NOT asio_POPULATED)
Expand Down
25 changes: 10 additions & 15 deletions boost/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.26)

set(PRJ_NAME "TestBoost")

project(${PRJ_NAME} VERSION 0.1.0 LANGUAGES C CXX)
project(${PRJ_NAME})
message(STATUS "start cmake ${PRJ_NAME} ...")

# enable c++20
Expand All @@ -14,9 +14,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(GetBoost)

# define head files and src files
File(GLOB hdrs ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
File(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
# define src files
file(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

# add target
add_executable(${PRJ_NAME})
Expand All @@ -25,15 +24,11 @@ add_executable(${PRJ_NAME})
target_sources(${PRJ_NAME} PRIVATE ${srcs})

# set head include path
target_include_directories(${PRJ_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(
${PRJ_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# set link target
target_link_libraries(${PRJ_NAME} PRIVATE
Boost::asio
)

# set build definitions(if any)
# target_compile_definitions(${PRJ_NAME} PRIVATE xxx)

# set misc
set_property(TARGET ${PRJ_NAME} PROPERTY UNITY_BUILD ON)
target_link_libraries(
${PRJ_NAME}
PRIVATE Boost::asio)
3 changes: 1 addition & 2 deletions boost/GetBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ message(STATUS "get boost ...")
FetchContent_Declare(
Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.81.0/boost-1.81.0.tar.xz
DOWNLOAD_EXTRACT_TIMESTAMP ON
)
DOWNLOAD_EXTRACT_TIMESTAMP ON)

FetchContent_GetProperties(Boost)
if(NOT Boost_POPULATED)
Expand Down
25 changes: 10 additions & 15 deletions cjson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.26)

set(PRJ_NAME "TestCJson")

project(${PRJ_NAME} VERSION 0.1.0 LANGUAGES C CXX)
project(${PRJ_NAME})
message(STATUS "start cmake ${PRJ_NAME} ...")

# download and import dep
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(GetCJson)

# define head files and src files
File(GLOB hdrs ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
File(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
# define src files
file(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

# add target
add_executable(${PRJ_NAME})
Expand All @@ -20,15 +19,11 @@ add_executable(${PRJ_NAME})
target_sources(${PRJ_NAME} PRIVATE ${srcs})

# set head include path
target_include_directories(${PRJ_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(
${PRJ_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# set link target
target_link_libraries(${PRJ_NAME} PRIVATE
cjson::cjson
)

# set build definitions(if any)
# target_compile_definitions(${PRJ_NAME} PRIVATE xxx)

# set misc
set_property(TARGET ${PRJ_NAME} PROPERTY UNITY_BUILD ON)
target_link_libraries(
${PRJ_NAME}
PRIVATE cjson::cjson)
21 changes: 14 additions & 7 deletions cjson/GetCJson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ message(STATUS "get cjson ...")

FetchContent_Declare(
cjson
URL https://github.com/DaveGamble/cJSON/archive/b45f48e600671feade0b6bd65d1c69de7899f2be.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
URL https://github.com/DaveGamble/cJSON/archive/b45f48e600671feade0b6bd65d1c69de7899f2be.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE)

FetchContent_GetProperties(cjson)
if(NOT cjson_POPULATED)
set(ENABLE_CJSON_UTILS OFF CACHE BOOL "")
set(ENABLE_CJSON_TEST OFF CACHE BOOL "")
set(CJSON_BUILD_SHARED_LIBS OFF CACHE BOOL "")
set(ENABLE_CJSON_UNINSTALL OFF CACHE BOOL "")
set(ENABLE_CJSON_UTILS
OFF
CACHE BOOL "")
set(ENABLE_CJSON_TEST
OFF
CACHE BOOL "")
set(CJSON_BUILD_SHARED_LIBS
OFF
CACHE BOOL "")
set(ENABLE_CJSON_UNINSTALL
OFF
CACHE BOOL "")

FetchContent_MakeAvailable(cjson)
target_include_directories(cjson PUBLIC $<BUILD_INTERFACE:${cjson_SOURCE_DIR}>)
Expand Down
25 changes: 10 additions & 15 deletions eigen3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.26)

set(PRJ_NAME "TestEigen3")

project(${PRJ_NAME} VERSION 0.1.0 LANGUAGES C CXX)
project(${PRJ_NAME})
message(STATUS "start cmake ${PRJ_NAME} ...")

# enable c++20
Expand All @@ -14,9 +14,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(GetEigen3)

# define head files and src files
File(GLOB hdrs ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
File(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
# define src files
file(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

# add target
add_executable(${PRJ_NAME})
Expand All @@ -25,15 +24,11 @@ add_executable(${PRJ_NAME})
target_sources(${PRJ_NAME} PRIVATE ${srcs})

# set head include path
target_include_directories(${PRJ_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(
${PRJ_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# set link target
target_link_libraries(${PRJ_NAME} PRIVATE
Eigen3::Eigen
)

# set build definitions(if any)
# target_compile_definitions(${PRJ_NAME} PRIVATE xxx)

# set misc
set_property(TARGET ${PRJ_NAME} PROPERTY UNITY_BUILD ON)
target_link_libraries(
${PRJ_NAME}
PRIVATE Eigen3::Eigen)
Loading

0 comments on commit 8a9bd29

Please sign in to comment.