Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set CMAKELIB_SRC_DIR as cache variable #8

Merged
merged 6 commits into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert "set cmake-format options dangle_parens"
This reverts commit d2225d9.
  • Loading branch information
aminya committed Oct 23, 2021
commit f89393fa4f32e16411a3bc562d04768121746423
2 changes: 1 addition & 1 deletion .cmake-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ format:
max_pargs_hwrap: 3
separate_ctrl_name_with_space: false
separate_fn_name_with_space: false
dangle_parens: true
dangle_parens: false
line_ending: unix
markup:
bullet_char: '*'
Expand Down
9 changes: 3 additions & 6 deletions src/Cache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
function(enable_cache)
set(CACHE_OPTION
"ccache"
CACHE STRING "Compiler cache to be used"
)
CACHE STRING "Compiler cache to be used")
set(CACHE_OPTION_VALUES "ccache" "sccache")
set_property(CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES})
list(
FIND
CACHE_OPTION_VALUES
${CACHE_OPTION}
CACHE_OPTION_INDEX
)
CACHE_OPTION_INDEX)

if(${CACHE_OPTION_INDEX} EQUAL -1)
message(
Expand All @@ -26,8 +24,7 @@ function(enable_cache)
message(STATUS "${CACHE_BINARY} found and enabled")
set(CMAKE_CXX_COMPILER_LAUNCHER
${CACHE_BINARY}
CACHE FILEPATH "compiler cache used"
)
CACHE FILEPATH "compiler cache used")
else()
message(WARNING "${CACHE_OPTION} is enabled but was not found. Not using it")
endif()
Expand Down
3 changes: 1 addition & 2 deletions src/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ function(
WARNINGS_AS_ERRORS
MSVC_WARNINGS
CLANG_WARNINGS
GCC_WARNINGS
)
GCC_WARNINGS)
if(NOT ${MSVC_WARNINGS})
set(MSVC_WARNINGS
/W4 # Baseline reasonable warnings
Expand Down
6 changes: 2 additions & 4 deletions src/Conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ macro(run_conan options)
DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake"
EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484
TLS_VERIFY ON
)
TLS_VERIFY ON)
endif()

set(ENV{CONAN_REVISIONS_ENABLED} 1)
Expand All @@ -21,8 +20,7 @@ macro(run_conan options)
conan_add_remote(
NAME cci
URL https://center.conan.io
INDEX 0
)
INDEX 0)
conan_add_remote(NAME bincrafters URL https://bincrafters.jfrog.io/artifactory/api/conan/public-conan)

# For multi configuration generators, like VS and XCode
Expand Down
3 changes: 1 addition & 2 deletions src/GlobalOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ set(args
ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
ENABLE_SANITIZER_THREAD
ENABLE_SANITIZER_MEMORY
)
ENABLE_SANITIZER_MEMORY)
foreach(opt ${args})
option(${opt} OFF)
if(${opt})
Expand Down
17 changes: 5 additions & 12 deletions src/Index.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.16)

set(CMAKELIB_SRC_DIR
${CMAKE_CURRENT_LIST_DIR}
CACHE FILEPATH ""
)
set(CMAKELIB_SRC_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE FILEPATH "")
ClausKlein marked this conversation as resolved.
Show resolved Hide resolved

include("${CMAKELIB_SRC_DIR}/PreventInSourceBuilds.cmake")

Expand Down Expand Up @@ -52,8 +49,7 @@ macro(cmakelib)
ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
ENABLE_SANITIZER_THREAD
ENABLE_SANITIZER_MEMORY
)
ENABLE_SANITIZER_MEMORY)
set(oneValueArgs
MSVC_WARNINGS
CLANG_WARNINGS
Expand Down Expand Up @@ -104,8 +100,7 @@ macro(cmakelib)
WARNINGS_AS_ERRORS=${cmakelib_WARNINGS_AS_ERRORS}
MSVC_WARNINGS=${cmakelib_MSVC_WARNINGS}
CLANG_WARNINGS=${cmakelib_CLANG_WARNINGS}
GCC_WARNINGS=${cmakelib_GCC_WARNINGS}
)
GCC_WARNINGS=${cmakelib_GCC_WARNINGS})

include("${CMAKELIB_SRC_DIR}/Tests.cmake")
if(${cmakelib_ENABLE_COVERAGE})
Expand All @@ -120,8 +115,7 @@ macro(cmakelib)
${cmakelib_ENABLE_SANITIZER_LEAK}
${cmakelib_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR}
${cmakelib_ENABLE_SANITIZER_THREAD}
${cmakelib_ENABLE_SANITIZER_MEMORY}
)
${cmakelib_ENABLE_SANITIZER_MEMORY})

if(${cmakelib_ENABLE_DOXYGEN})
# enable doxygen
Expand Down Expand Up @@ -154,8 +148,7 @@ macro(cmakelib)
<vector>
<string>
<map>
<utility>
)
<utility>)
endif()

if(${cmakelib_ENABLE_CONAN})
Expand Down
11 changes: 4 additions & 7 deletions src/Linker.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ macro(configure_linker project_name)
include(CheckCXXCompilerFlag)

set(USER_LINKER_OPTION
"lld"
CACHE STRING "Linker to be used"
)
"lld"
CACHE STRING "Linker to be used")
set(USER_LINKER_OPTION_VALUES "lld" "gold" "bfd")
set_property(CACHE USER_LINKER_OPTION PROPERTY STRINGS ${USER_LINKER_OPTION_VALUES})
list(
FIND
USER_LINKER_OPTION_VALUES
${USER_LINKER_OPTION}
USER_LINKER_OPTION_INDEX
)
USER_LINKER_OPTION_INDEX)

if(${USER_LINKER_OPTION_INDEX} EQUAL -1)
message(
STATUS
"Using custom linker: '${USER_LINKER_OPTION}', explicitly supported entries are ${USER_LINKER_OPTION_VALUES}"
)
"Using custom linker: '${USER_LINKER_OPTION}', explicitly supported entries are ${USER_LINKER_OPTION_VALUES}")
endif()

if(NOT ENABLE_USER_LINKER)
Expand Down
2 changes: 1 addition & 1 deletion src/PreventInSourceBuilds.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ function(AssureOutOfSourceBuilds)
endif()
endfunction()

assureoutofsourcebuilds()
AssureOutOfSourceBuilds()
7 changes: 3 additions & 4 deletions src/StandardProjectSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Choose the type of build." FORCE
)
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui, ccmake
set_property(
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS
"Debug"
"Release"
"MinSizeRel"
"RelWithDebInfo"
)
"RelWithDebInfo")
endif()

# Generate compile_commands.json to make it easier to work with clang based tools
Expand All @@ -26,3 +24,4 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
else()
message(STATUS "No colored compiler diagnostic set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif()

3 changes: 1 addition & 2 deletions src/StaticAnalyzers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ macro(enable_cppcheck)
--suppress=missingInclude
--enable=all
--inline-suppr
--inconclusive
)
--inconclusive)
if(WARNINGS_AS_ERRORS)
list(APPEND CMAKE_CXX_CPPCHECK --error-exitcode=2)
endif()
Expand Down
1 change: 1 addition & 0 deletions src/Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ function(enable_coverage project_name)
target_link_libraries(${project_name} INTERFACE --coverage)
endif()
endfunction()

3 changes: 1 addition & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ cmake_minimum_required(VERSION 3.16...3.21)
project(
escape
VERSION 0.1.0
LANGUAGES CXX
)
LANGUAGES CXX)

### Add cmakelib
# include(FetchContent)
Expand Down