mirror of
https://github.com/JHUAPL/kami.git
synced 2026-01-09 14:58:02 -05:00
Some cleanups to cmake build process
This commit is contained in:
@@ -1,43 +1,16 @@
|
||||
#
|
||||
# This is the Top level CMakelists file which creates the namespace and
|
||||
# organizes all sublibraries under it.
|
||||
#
|
||||
# The project name in this file is considered the "Namespace"
|
||||
# and any libraries under it will be given a target of
|
||||
#
|
||||
# Namespace::library_name
|
||||
#
|
||||
#
|
||||
# This Lists file was modified from https://github.com/forexample/package-example
|
||||
#
|
||||
# This file creates project 'Foo' with two library targets 'bar' and 'cat'.
|
||||
# Target 'cat' depends on 'bar'. After installation this project can be found
|
||||
# by 'find_package(... CONFIG)' command:
|
||||
#
|
||||
# find_package(foo CONFIG REQUIRED)
|
||||
# target_link_libraries(... foo::bar)
|
||||
#
|
||||
# Note that requirements propagated automatically, for example:
|
||||
# * Foo::baz linked automatically
|
||||
# * <prefix>/include added to header search path
|
||||
# * FOO_BAZ_DEBUG=1/FOO_BAR_DEBUG=1 added on Debug
|
||||
# * FOO_BAZ_DEBUG=0/FOO_BAR_DEBUG=0 added on other configurations
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
####
|
||||
# Set minimum version of CMake. We need 3.13 at least.
|
||||
cmake_minimum_required(VERSION 3.13) # GENERATOR_IS_MULTI_CONFIG
|
||||
set(PROJECT_NAME "kami")
|
||||
|
||||
set(KAMI_VERSION_MAJOR 0)
|
||||
set(KAMI_VERSION_MINOR 5)
|
||||
set(KAMI_VERSION_PATCH 0)
|
||||
set(KAMI_VERSION_STRING ${KAMI_VERSION_MAJOR}.${KAMI_VERSION_MINOR}.${KAMI_VERSION_PATCH})
|
||||
set(VERSION_MAJOR 0)
|
||||
set(VERSION_MINOR 5)
|
||||
set(VERSION_PATCH 0)
|
||||
set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
||||
|
||||
################################################################################
|
||||
# Set variables for the project. The:
|
||||
# * PROJECT_NAME
|
||||
# * PROJECT_VERSION
|
||||
# * PROJECT_NAMESPACE should be the same as the project.
|
||||
project(kami VERSION ${KAMI_VERSION_STRING}
|
||||
project(${PROJECT_NAME}
|
||||
VERSION ${VERSION_STRING}
|
||||
LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
@@ -48,11 +21,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_BINARY_DIR}" CACHE STRING "M
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
|
||||
set(PROJECT_NAMESPACE kami ) # The project namespace. Library targets
|
||||
# will be referred by
|
||||
# foo::bar. This value should usually be
|
||||
# the same as the project.
|
||||
################################################################################
|
||||
set(PROJECT_NAMESPACE ${PROJECT_NAME})
|
||||
|
||||
find_package(spdlog)
|
||||
find_package(Threads)
|
||||
@@ -95,7 +64,7 @@ ENDFOREACH()
|
||||
################################################################################
|
||||
# Examples.
|
||||
#
|
||||
# Each example will be built as a static or shared library and a
|
||||
# Each example will be built as a static or shared binary and a
|
||||
# target will be created for it.
|
||||
################################################################################
|
||||
|
||||
@@ -159,11 +128,8 @@ configure_package_config_file(
|
||||
# * header location after install: <prefix>/include/foo/Bar.hpp
|
||||
# * headers can be included by C++ code `#include <foo/Bar.hpp>`
|
||||
install(
|
||||
TARGETS
|
||||
${sub_modules} ${example_modules}
|
||||
${COVERAGE_INSTALL_TARGET}
|
||||
EXPORT
|
||||
"${TARGETS_EXPORT_NAME}"
|
||||
TARGETS ${sub_modules} ${example_modules} ${COVERAGE_INSTALL_TARGET}
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
@@ -175,21 +141,16 @@ configure_package_config_file(
|
||||
# * <prefix>/lib/cmake/Foo/FooConfig.cmake
|
||||
# * <prefix>/lib/cmake/Foo/FooConfigVersion.cmake
|
||||
install(
|
||||
FILES
|
||||
"${project_config}" "${version_config}"
|
||||
DESTINATION
|
||||
"${config_install_dir}"
|
||||
FILES "${project_config}" "${version_config}"
|
||||
DESTINATION "${config_install_dir}"
|
||||
)
|
||||
|
||||
# Config
|
||||
# * <prefix>/lib/cmake/Foo/FooTargets.cmake
|
||||
install(
|
||||
EXPORT
|
||||
"${TARGETS_EXPORT_NAME}"
|
||||
NAMESPACE
|
||||
"${namespace}"
|
||||
DESTINATION
|
||||
"${config_install_dir}"
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
NAMESPACE "${namespace}"
|
||||
DESTINATION "${config_install_dir}"
|
||||
)
|
||||
|
||||
add_subdirectory(docs)
|
||||
|
||||
@@ -15,4 +15,4 @@ create_executable(
|
||||
PUBLIC_LINKED_TARGETS fmt spdlog::spdlog kami::libkami
|
||||
)
|
||||
|
||||
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${KAMI_VERSION_STRING})
|
||||
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${VERSION_STRING})
|
||||
|
||||
@@ -15,4 +15,4 @@ create_executable(
|
||||
PUBLIC_LINKED_TARGETS fmt spdlog::spdlog kami::libkami
|
||||
)
|
||||
|
||||
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${KAMI_VERSION_STRING})
|
||||
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${VERSION_STRING})
|
||||
|
||||
@@ -15,4 +15,4 @@ create_executable(
|
||||
PUBLIC_LINKED_TARGETS fmt spdlog::spdlog kami::libkami
|
||||
)
|
||||
|
||||
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${KAMI_VERSION_STRING})
|
||||
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${VERSION_STRING})
|
||||
|
||||
@@ -41,25 +41,23 @@
|
||||
/**
|
||||
* The major version of the Kami library.
|
||||
*/
|
||||
#define KAMI_VERSION_MAJOR @KAMI_VERSION_MAJOR@
|
||||
#define KAMI_VERSION_MAJOR @VERSION_MAJOR@
|
||||
|
||||
/**
|
||||
* The minor version of the Kami library.
|
||||
*/
|
||||
#define KAMI_VERSION_MINOR @KAMI_VERSION_MINOR@
|
||||
#define KAMI_VERSION_MINOR @VERSION_MINOR@
|
||||
|
||||
/**
|
||||
* The patch level of the Kami library.
|
||||
*/
|
||||
#define KAMI_VERSION_PATCH @KAMI_VERSION_PATCH@
|
||||
#define KAMI_VERSION_PATCH @VERSION_PATCH@
|
||||
|
||||
namespace kami {
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @brief A reference copy of the current version of Kami
|
||||
*
|
||||
* @return the version as a `semver` object
|
||||
*/
|
||||
constexpr auto version = semver::version{KAMI_VERSION_MAJOR, KAMI_VERSION_MINOR, KAMI_VERSION_PATCH};
|
||||
}
|
||||
|
||||
@@ -2,11 +2,17 @@
|
||||
# Set minimum version of CMake.
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
project(libkami VERSION ${KAMI_VERSION_STRING}
|
||||
set(LIBRARY_NAME "libkami")
|
||||
|
||||
project(${LIBRARY_NAME} LANGUAGES CXX)
|
||||
|
||||
project(${LIBRARY_NAME}
|
||||
VERSION ${VERSION_STRING}
|
||||
LANGUAGES CXX)
|
||||
|
||||
create_library(NAME libkami
|
||||
NAMESPACE libkami
|
||||
create_library(
|
||||
NAME ${LIBRARY_NAME}
|
||||
NAMESPACE ${LIBRARY_NAME}
|
||||
SOURCES
|
||||
agent.cc
|
||||
domain.cc
|
||||
@@ -21,22 +27,22 @@ create_library(NAME libkami
|
||||
sologrid1d.cc
|
||||
sologrid2d.cc
|
||||
staged.cc
|
||||
PUBLIC_INCLUDE_PATHS
|
||||
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_headers>"
|
||||
PRIVATE_LINKED_TARGETS
|
||||
${COVERAGE_TARGET}
|
||||
EXPORT_FILE_PATH
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/KAMI_EXPORT.h"
|
||||
PUBLIC_INCLUDE_PATHS "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_headers>"
|
||||
PRIVATE_LINKED_TARGETS ${COVERAGE_TARGET}
|
||||
EXPORT_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/KAMI_EXPORT.h"
|
||||
)
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/include/kami/config.h.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/config.h")
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/config.h"
|
||||
)
|
||||
|
||||
set_target_properties(libkami PROPERTIES VERSION ${KAMI_VERSION_STRING}
|
||||
SOVERSION ${KAMI_VERSION_MAJOR}
|
||||
OUTPUT_NAME kami)
|
||||
set_target_properties(
|
||||
${LIBRARY_NAME}
|
||||
PROPERTIES VERSION ${VERSION_STRING}
|
||||
SOVERSION ${VERSION_MAJOR}
|
||||
OUTPUT_NAME kami
|
||||
)
|
||||
|
||||
# Introduce variables:
|
||||
# * CMAKE_INSTALL_LIBDIR
|
||||
|
||||
@@ -29,6 +29,14 @@ create_test(
|
||||
PUBLIC_COMPILE_FEATURES ${COVERAGE_FLAGS}
|
||||
)
|
||||
|
||||
create_test(
|
||||
NAME unit-kami-multigrid1d
|
||||
SOURCES unit-kami-multigrid1d.cc
|
||||
PUBLIC_LINKED_TARGETS gmock gtest kami::libkami Threads::Threads
|
||||
COMMAND unit-kami-multigrid1d
|
||||
PUBLIC_COMPILE_FEATURES ${COVERAGE_FLAGS}
|
||||
)
|
||||
|
||||
create_test(
|
||||
NAME unit-kami-stagedagent
|
||||
SOURCES unit-kami-stagedagent.cc
|
||||
|
||||
Reference in New Issue
Block a user