Make the Cmake files a Cmake library
aminya opened this issue · comments
Whenever I want to use this project, I have to copy a bunch of boilerplate Cmake code to different places, which is rather inconvenient and error-prone. It would be nice if the code can become a Cmake library to solve this issue of copying.
By library I mean something similar to ixm:
https://ixm.one/
This is all I need to install ixm
:
include(FetchContent)
FetchContent_Declare(ixm URL https://get.ixm.one)
FetchContent_MakeAvailable(ixm)
I had no idea that people did this.
Yeah. This is a cool idea! The files under the CMake folder can become general enough to be reusable this way. IXM support some interesting toolchains, which we can potentially use!
I have started making the Cmake library reusable:
https://github.com/aminya/cmakelib
The Index.cmake
file can be included, and then the top-level CmakeLists.txt
would be much simpler.
cmake_minimum_required(VERSION 3.15)
# Set the project name to your project name, my project isn't very descriptive
project(myproject CXX)
# Add cmakelib
include(FetchContent)
FetchContent_Declare(cmakelib URL https://github.com/aminya/cmakelib/archive/refs/heads/main.zip)
FetchContent_MakeAvailable(cmakelib)
include(${cmakelib_SOURCE_DIR}/Index.cmake)
# Initialize cmakelib
# uncomment the options to enable them
cmakelib(
Enable_CACHE
ENABLE_CONAN
# WARNINGS_AS_ERRORS
# ENABLE_CPPCHECK
# ENABLE_CLANG_TIDY
# ENABLE_INCLUDE_WHAT_YOU_USE
# ENABLE_COVERAGE
# ENABLE_PCH
# ENABLE_DOXYGEN
# ENABLE_IPO
# ENABLE_USER_LINKER
# ENABLE_BUILD_WITH_TIME_TRACE
# ENABLE_UNITY
# ENABLE_SANITIZER_ADDRESS
# ENABLE_SANITIZER_LEAK
# ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
# ENABLE_SANITIZER_THREAD
# ENABLE_SANITIZER_MEMORY
)
# project_options is defined inside cmakelib
target_compile_features(project_options INTERFACE cxx_std_17)
# add src, tests, etc here:
@lefticus I would like to transfer that repository to this organization so we can work on it together. Can I get an invitation to the organization so I can transfer it?