Welcome to JCM’s documentation!¶
jgd-cmake-modules¶
CMake library of CMake modules to easily and consistently develop proper CMake projects.
Pages¶
- Getting Started
- Overview
- Find Modules
- Modules
- JcmAllModules
- JcmSetupProject
- JcmAddExecutable
- JcmAddLibrary
- JcmAddTestExecutable
- JcmSourceSubdirectories
- JcmTargetSources
- JcmCreateAccessoryTargets
- JcmAddOption
- JcmBasicPackageConfig
- JcmInstallConfigFilePackage
- JcmDefaultCompileOptions
- JcmTargetNaming
- JcmFileNaming
- JcmCanonicalStructure
- JcmConfigureFiles
- JcmParseArguments
- JcmStandardDirs
- JcmHeaderFileSet
- JcmListTransformations
- JcmExpandDirectories
- JcmSymlinks
- JcmArbitraryScript
- Building Tests & Docs
- tests
- How to Build CMake Projects
Indices¶
Sample¶
cmake_minimum_required(VERSION 3.24) project(libsingle VERSION 0.0.0 LANGUAGES CXX) find_package(jgd-cmake-modules CONFIG REQUIRED) find_package(ClangFormat) if(LIBSINGLE_ENABLE_DOCS) find_package(Doxygen REQUIRED COMPONENTS doxygen) endif() include(JcmAllModules) jcm_setup_project() jcm_source_subdirectories( ADD_SUBDIRS WITH_TESTS_DIR WITH_DOCS_DIR) jcm_create_clang_format_targets( SOURCE_TARGETS libsingle::libsingle) jcm_install_config_file_package( INSTALL_LICENSES CONFIGURE_PACKAGE_CONFIG_FILES TARGETS libsingle::libsingle)jcm_configure_file( IN_FILE libsingle_config.hpp.in OUT_FILE_VAR configured_header) jcm_add_library( OUT_TARGET target PUBLIC_HEADERS widget.hpp factory.hpp PRIVATE_HEADERS "${configured_header}" SOURCES widget.cpp factory.cpp) # a subdirectory that's "complex" enough to warrant a separate CMakeLists.txt file. add_subdirectory(material) target_compile_features(${target} PRIVATE cxx_std_17) jcm_add_test_executable( NAME widget-unit-test SOURCES widget.test.cpp LIBS libsingle::libsingle)include(JcmTargetSources) jcm_add_target_sources( TARGET libsingle::libsingle PUBLIC_HEADERS steal.hpp SOURCES steal.cpp)jcm_add_test_executable( NAME ${PROJECT_NAME}-integration-test SOURCES test.cpp LIBS libsingle::libsingle)jcm_create_doxygen_target( README_MAIN_PAGE SOURCE_TARGETS libsingle::libsingle EXCLUDE_REGEX "export_macros.hpp$")@PACKAGE_INIT@ include(CMakeFindDependencyMacro) find_dependency(jgd-cmake-modules CONFIG REQUIRED) include(JcmBasicPackageConfig) jcm_basic_package_config(@PROJECT_NAME@)
Examples¶
This project uses its own modules, and acts as its own example!
Additionally, the tests/ directory has sample projects that use jgd-cmake-modules. Each project acts as an example of using jgd-cmake-modules and the Canonical Project Structure.