From c74446c3e6a88ffbb13743dcc9f3b93d10aa009d Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sun, 10 Feb 2019 22:41:15 +0100 Subject: Add CMake configuration, delete ninja files The new CMake configuration builds only static libraries --- CMakeLists.txt | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 CMakeLists.txt (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c31e16b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,107 @@ +cmake_minimum_required(VERSION 3.10) +project( + MM + VERSION 0.1 + DESCRIPTION "MiniMath, a mathematical library that (ab)uses abstraction" + LANGUAGES CXX +) + +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake) + +############################ +# build libmm +add_library(mm STATIC + mmvec.cpp +) + +add_library(MM:mm ALIAS mm) + +# set up headers +target_include_directories(mm + PUBLIC + $ + $ + PRIVATE + ${CMAKE_CURRENT_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include/mm +) + +target_compile_options(mm + PRIVATE + $<$: + -pedantic -Wall -Wextra -Wcast-qual -Wcast-align -Wpointer-arith + -Winit-self -Wshadow -Wswitch-enum -Wredundant-decls -Wfloat-equal + -Wundef -Wvla -Wconversion -Wstrict-aliasing + > + $<$:/W4> +) + +target_compile_definitions(mm + PRIVATE + $<$:DEBUG> +) + +# set compiler features +# For a complete list see: +# https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html +target_compile_features(mm + PRIVATE + cxx_std_17 +) + + +############################ +# installation +include(GNUInstallDirs) +set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/MM) + +install(TARGETS mm + EXPORT mm-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +set_target_properties(mm PROPERTIES EXPORT_NAME MM) + +# install public headers +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# export targets +install(EXPORT mm-targets + FILE + MMTargets.cmake + NAMESPACE + MM:: + DESTINATION + ${INSTALL_CONFIGDIR} +) + +# create ConfigVersion.cmake +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/MMConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion +) + +configure_package_config_file( + ${CMAKE_CURRENT_LIST_DIR}/cmake/MMConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/MMConfig.cmake + INSTALL_DESTINATION ${INSTALL_CONFIGDIR} +) + +# install config, configversion +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/MMConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/MMConfigVersion.cmake + DESTINATION ${INSTALL_CONFIGDIR} +) + +############################ +# export from the build tree +export(EXPORT mm-targets + FILE ${CMAKE_CURRENT_BINARY_DIR}/MMTargets.cmake + NAMESPACE MM:: +) + +export(PACKAGE MM) -- cgit v1.2.1 From 94d90dd045463a540fe14880b1c04e2ce44a1efe Mon Sep 17 00:00:00 2001 From: ancarola Date: Mon, 11 Feb 2019 12:48:58 +0100 Subject: CMakeLists: include fixes, include tree structure modified --- CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index c31e16b..6e7d073 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,8 +63,20 @@ install(TARGETS mm set_target_properties(mm PROPERTIES EXPORT_NAME MM) + +if ("${CMAKE_SYSTEM}" MATCHES "Linux") + +# too bad but no other simpler choise +file(GLOB INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/*") + # install public headers -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${INCLUDE_FILES} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mm +) + +endif() + +# TODO, install setup for windows too # export targets install(EXPORT mm-targets -- cgit v1.2.1 From d14d1a12fa0a8c6f60385468f18f99d799d7a5db Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 11 Feb 2019 14:24:59 +0100 Subject: Fix typos and other minor errors --- CMakeLists.txt | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e7d073..c7918e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,10 +11,10 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake) ############################ # build libmm add_library(mm STATIC - mmvec.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mmvec.cpp ) -add_library(MM:mm ALIAS mm) +add_library(MM::mm ALIAS mm) # set up headers target_include_directories(mm @@ -64,20 +64,15 @@ install(TARGETS mm set_target_properties(mm PROPERTIES EXPORT_NAME MM) -if ("${CMAKE_SYSTEM}" MATCHES "Linux") - -# too bad but no other simpler choise -file(GLOB INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/*") - # install public headers -install(FILES ${INCLUDE_FILES} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mm +install( + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/include/mmvec.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/include/mm + DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/mm ) -endif() - -# TODO, install setup for windows too - # export targets install(EXPORT mm-targets FILE -- cgit v1.2.1