diff --git a/.appveyor.yml b/.appveyor.yml index cd83435..d6f94b2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,35 +2,21 @@ version: build-{branch}-#{build} branches: only: - - master - # - develop + # - master + - develop environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - GENERATOR: "Visual Studio 15 2017 Win64" CONFIG: Release - VCPATH: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - GENERATOR: "Visual Studio 16 2019" - CMAKE_ARCH: -A x64 CONFIG: Release - VCPATH: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community" - -# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 -# GENERATOR: "Visual Studio 16 2019" -# CMAKE_ARCH: -A x64 -# CMAKE_TOOLKIT: -T ClangCl -# CONFIG: Release -# VCPATH: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community" build_script: - - cmd: call "%VCPATH%\VC\Auxiliary\Build\vcvars64.bat" - cmd: mkdir build - cmd: cd build - - cmd: echo Executing cmake -G %GENERATOR% %CMAKE_ARCH% %CMAKE_TOOLKIT% - - cmd: cmake "-G%GENERATOR%" %CMAKE_ARCH% %CMAKE_TOOLKIT% -DCMAKE_CXX_STANDARD=11 -DCML_BUILD_TESTING=ON .. + - cmd: cmake .. -GNinja -DCML_BUILD_TESTING=ON - cmd: cmake --build . --config "%CONFIG%" test_script: diff --git a/CML.cmake b/CML.cmake index 13fc9c9..f0b0173 100644 --- a/CML.cmake +++ b/CML.cmake @@ -2,12 +2,6 @@ # @@COPYRIGHT@@ #*------------------------------------------------------------------------- -if(${CMAKE_GENERATOR} MATCHES "Visual Studio") - set(_header_group "Header Files\\") -else() - set(_header_group) -endif() - set(main_HEADERS cml/cml.h cml/matrix.h @@ -17,7 +11,6 @@ set(main_HEADERS cml/vector.h cml/version.h ) -source_group("${_header_group}" FILES ${main_HEADERS}) set(common_HEADERS cml/common/array_size_of.h @@ -33,7 +26,6 @@ set(common_HEADERS cml/common/traits.h cml/common/type_util.h ) -source_group("${_header_group}common" FILES ${common_HEADERS}) set(common_mpl_HEADERS cml/common/mpl/are_convertible.h @@ -56,7 +48,6 @@ set(common_mpl_HEADERS cml/common/mpl/type_map.h cml/common/mpl/type_table.h ) -source_group("${_header_group}common\\mpl" FILES ${common_mpl_HEADERS}) set(scalar_HEADERS cml/scalar/binary_ops.h @@ -66,7 +57,6 @@ set(scalar_HEADERS cml/scalar/traits.h cml/scalar/unary_ops.h ) -source_group("${_header_group}scalar" FILES ${scalar_HEADERS}) set(storage_HEADERS cml/storage/allocated_selector.h @@ -78,7 +68,6 @@ set(storage_HEADERS cml/storage/selectors.h cml/storage/type_util.h ) -source_group("${_header_group}storage" FILES ${storage_HEADERS}) set(vector_HEADERS cml/vector/binary_node.h @@ -145,14 +134,12 @@ set(vector_HEADERS cml/vector/writable_vector.h cml/vector/writable_vector.tpp ) -source_group("${_header_group}vector" FILES ${vector_HEADERS}) set(vector_detail_HEADERS cml/vector/detail/check_or_resize.h cml/vector/detail/combined_size_of.h cml/vector/detail/resize.h ) -source_group("${_header_group}vector\\detail" FILES ${vector_detail_HEADERS}) set(matrix_HEADERS cml/matrix/array_size_of.h @@ -221,7 +208,6 @@ set(matrix_HEADERS cml/matrix/writable_matrix.h cml/matrix/writable_matrix.tpp ) -source_group("${_header_group}matrix" FILES ${matrix_HEADERS}) set(matrix_detail_HEADERS cml/matrix/detail/apply.h @@ -237,7 +223,6 @@ set(matrix_detail_HEADERS cml/matrix/detail/resize.h cml/matrix/detail/transpose.h ) -source_group("${_header_group}matrix\\detail" FILES ${matrix_detail_HEADERS}) set(quaternion_HEADERS cml/quaternion/binary_node.h @@ -291,7 +276,6 @@ set(quaternion_HEADERS cml/quaternion/writable_quaternion.h cml/quaternion/writable_quaternion.tpp ) -source_group("${_header_group}quaternion" FILES ${quaternion_HEADERS}) set(mathlib_HEADERS cml/mathlib/axis_order.h @@ -305,7 +289,6 @@ set(mathlib_HEADERS cml/mathlib/random_unit.h cml/mathlib/random_unit.tpp ) -source_group("${_header_group}mathlib" FILES ${mathlib_HEADERS}) set(mathlib_vector_HEADERS cml/mathlib/vector/angle.h @@ -321,7 +304,6 @@ set(mathlib_vector_HEADERS cml/mathlib/vector/transform.h cml/mathlib/vector/transform.tpp ) -source_group("${_header_group}mathlib\\vector" FILES ${mathlib_vector_HEADERS}) set(mathlib_matrix_HEADERS cml/mathlib/matrix/basis.h @@ -347,7 +329,6 @@ set(mathlib_matrix_HEADERS cml/mathlib/matrix/translation.h cml/mathlib/matrix/translation.tpp ) -source_group("${_header_group}mathlib\\matrix" FILES ${mathlib_matrix_HEADERS}) set(mathlib_quaternion_HEADERS cml/mathlib/quaternion/basis.h @@ -355,8 +336,6 @@ set(mathlib_quaternion_HEADERS cml/mathlib/quaternion/rotation.h cml/mathlib/quaternion/rotation.tpp ) -source_group("${_header_group}mathlib\\quaternion" - FILES ${mathlib_quaternion_HEADERS}) set(util_HEADERS cml/util/matrix_print.h @@ -367,7 +346,6 @@ set(util_HEADERS cml/util/vector_print.h cml/util/vector_print.tpp ) -source_group("${_header_group}\\util" FILES ${util_HEADERS}) set(all_headers ${main_HEADERS} @@ -387,10 +365,33 @@ set(all_headers ${mathlib_quaternion_HEADERS} ) +add_library(cml INTERFACE) +target_compile_options(cml INTERFACE $<$:/permissive->) +target_compile_features(cml INTERFACE + cxx_reference_qualified_functions + cxx_constexpr + cxx_defaulted_functions + ) target_include_directories(cml INTERFACE $) +target_include_directories(cml INTERFACE $/include>) -option(CML_ENABLE_DEV - "Enable the cml-dev custom target to see headers to an IDE" OFF) -if(CML_ENABLE_DEV) - add_custom_target(cml-dev SOURCES ${all_headers}) -endif() \ No newline at end of file +# Setup a custom target, and use IDE groups for the headers when possible: +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") + set(_header_group "Header Files\\") + source_group("${_header_group}" FILES ${main_HEADERS}) + source_group("${_header_group}common" FILES ${common_HEADERS}) + source_group("${_header_group}common\\mpl" FILES ${common_mpl_HEADERS}) + source_group("${_header_group}scalar" FILES ${scalar_HEADERS}) + source_group("${_header_group}storage" FILES ${storage_HEADERS}) + source_group("${_header_group}vector" FILES ${vector_HEADERS}) + source_group("${_header_group}vector\\detail" FILES ${vector_detail_HEADERS}) + source_group("${_header_group}matrix" FILES ${matrix_HEADERS}) + source_group("${_header_group}matrix\\detail" FILES ${matrix_detail_HEADERS}) + source_group("${_header_group}quaternion" FILES ${quaternion_HEADERS}) + source_group("${_header_group}mathlib" FILES ${mathlib_HEADERS}) + source_group("${_header_group}mathlib\\vector" FILES ${mathlib_vector_HEADERS}) + source_group("${_header_group}mathlib\\matrix" FILES ${mathlib_matrix_HEADERS}) + source_group("${_header_group}mathlib\\quaternion" FILES ${mathlib_quaternion_HEADERS}) + source_group("${_header_group}\\util" FILES ${util_HEADERS}) +endif() +add_custom_target(cml-dev SOURCES ${all_headers}) \ No newline at end of file diff --git a/CMake/cml-config.cmake b/CMake/cml-config.cmake new file mode 100644 index 0000000..1b4fe12 --- /dev/null +++ b/CMake/cml-config.cmake @@ -0,0 +1,2 @@ +include("${CMAKE_CURRENT_LIST_DIR}/cml-targets.cmake") +add_library(cml INTERFACE IMPORTED) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d9158d..878b871 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ #*------------------------------------------------------------------------- # Set the minimum CMake version: -cmake_minimum_required(VERSION 3.12.4) +cmake_minimum_required(VERSION 3.15) # Allow solution folders: set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -24,21 +24,14 @@ include(CMLBuildMacros) # is from the root Boost.CMake CMakeLists.txt file): cml_version_from_file( ${CML_ROOT}/cml/version.h # Path to version.h - "CML_VERSION" # The macro name to find - CML_VERSION_MAJOR # Parsed major version - CML_VERSION_MINOR # Parsed minor version - CML_VERSION_PATCH # Parsed patch version - CML_VERSION # String MM.mm.pp + "CML_VERSION" # The macro name to find + CML_VERSION_MAJOR # Parsed major version + CML_VERSION_MINOR # Parsed minor version + CML_VERSION_PATCH # Parsed patch version + CML_VERSION # String MM.mm.pp ) message(STATUS "Building CML ${CML_VERSION}") -# Define the CML interface library and required C++ features: -add_library(cml INTERFACE) -target_compile_features(cml INTERFACE - cxx_reference_qualified_functions # "rvalue reference from *this" - cxx_constexpr -) - # Create the CML interface library: include(CML.cmake) @@ -47,4 +40,24 @@ option(CML_BUILD_TESTING "Build CML tests" OFF) if(CML_BUILD_TESTING) enable_testing() add_subdirectory(tests) -endif() \ No newline at end of file +endif() + +# Installation and packaging: +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/cml-config-version.cmake + VERSION ${CML_VERSION} + COMPATIBILITY ExactVersion +) + +include(GNUInstallDirs) +install(TARGETS cml DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT cml-targets) +install(EXPORT cml-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cml FILE cml-targets.cmake) +install(DIRECTORY cml DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*") +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/cml-config-version.cmake + CMake/cml-config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cml + ) + + export(EXPORT cml-targets FILE cml-config.cmake) \ No newline at end of file diff --git a/cml/common/compiler.h b/cml/common/compiler.h index 7d5bc22..0759f8a 100644 --- a/cml/common/compiler.h +++ b/cml/common/compiler.h @@ -25,36 +25,4 @@ # define CML_HAS_STRUCTURED_BINDINGS #endif -#if defined(__GNUC__) && (__GNUC__ > 4 \ - || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9))) - -/* Defaulted move constructor supported: */ -# define CML_HAS_DEFAULTED_MOVE_CONSTRUCTOR - -#elif defined(__clang__) -/* Note: checking for Clang BEFORE checking for Visual Studio, since clang-cl - * defines _MSC_VER. - */ - -/* Defaulted move constructor: */ -# if ((__clang_major__ >= 4) \ - || ((__clang_major__ >= 3) && (__clang_minor__ >= 5))) \ - || (__apple_build_version__ >= 7000000) - -# define CML_HAS_DEFAULTED_MOVE_CONSTRUCTOR -# endif - -#elif defined(_MSC_VER) - -# if(_MSC_VER < 1914) -/* Apparently, VS2015 does not allow a parameter pack expansion to target non- - * packed parameters. - */ -# define CML_HAS_MSVC_WONKY_PARAMETER_PACK -# endif - -#else -#error "Unsupported compiler." -#endif - #endif \ No newline at end of file