From 15158e8aa906365cd2219dbb37352345d8ab5bf1 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Fri, 1 Nov 2019 11:16:31 -0600 Subject: [PATCH 1/7] Add a CMake Package config --- .appveyor.yml | 6 ++ .gitignore | 3 + .travis.yml | 185 +++++++++++++++++++++++++++++++++++ glmConfig-version.cmake | 13 +++ glmConfig.cmake | 13 +++ manual.md | 5 + test/cmake/CMakeLists.txt | 8 ++ test/cmake/test_find_glm.cpp | 22 +++++ 8 files changed, 255 insertions(+) create mode 100644 glmConfig-version.cmake create mode 100644 glmConfig.cmake create mode 100644 test/cmake/CMakeLists.txt create mode 100644 test/cmake/test_find_glm.cpp diff --git a/.appveyor.yml b/.appveyor.yml index 5b018cd0..9912ffc3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -67,5 +67,11 @@ build_script: test_script: - ctest -j4 -C %CONFIGURATION% + - cd .. + - ps: | + mkdir build_test_cmake + cd build_test_cmake + cmake ..\test\cmake\ -G "$env:generator" -Dglm_DIR="$env:APPVEYOR_BUILD_FOLDER" + - cmake --build . --config %CONFIGURATION% -- /m /v:minimal deploy: off diff --git a/.gitignore b/.gitignore index a0a1fc88..9dbd6d8c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,8 @@ CMakeFiles cmake_install.cmake install_manifest.txt *.cmake +!glmConfig.cmake +!glmConfig-version.cmake # ^ May need to add future .cmake files as exceptions # Test logs @@ -56,3 +58,4 @@ build* /.vscode /CMakeSettings.json .DS_Store +*.swp diff --git a/.travis.yml b/.travis.yml index 737f7560..5bb524bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_DISABLE_AUTO_DETECTION=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++unknown-release" @@ -23,6 +28,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++98-pure-release" @@ -35,6 +45,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++98-pure-ms-release" @@ -47,6 +62,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++11-pure-release" @@ -59,6 +79,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE2=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++11-sse2-release" @@ -71,6 +96,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++14-pure-release" @@ -83,6 +113,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++14-sse3-release" @@ -95,6 +130,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++14-avx-release" @@ -107,6 +147,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++14-avx-debug" @@ -119,6 +164,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++17-pure-release" @@ -131,6 +181,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++17-pure-debug" @@ -143,6 +198,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++17-avx-release" @@ -155,6 +215,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++17-avx-debug" @@ -174,6 +239,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -191,6 +261,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -208,6 +283,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -225,6 +305,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -242,6 +327,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -259,6 +349,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -276,6 +371,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -293,6 +393,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -310,6 +415,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -327,6 +437,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -344,6 +459,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -361,6 +481,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -378,6 +503,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE2=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -395,6 +525,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -412,6 +547,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -429,6 +569,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX2=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -447,6 +592,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -465,6 +615,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -483,6 +638,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic @@ -495,6 +655,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic @@ -507,6 +672,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic @@ -519,6 +689,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic @@ -531,6 +706,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic @@ -543,6 +723,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . before_install: - eval "${MATRIX_EVAL}" diff --git a/glmConfig-version.cmake b/glmConfig-version.cmake new file mode 100644 index 00000000..69837ee6 --- /dev/null +++ b/glmConfig-version.cmake @@ -0,0 +1,13 @@ +set(PACKAGE_VERSION 0.9.9) + +if(${PACKAGE_FIND_VERSION_MAJOR} EQUAL 0) + if (${PACKAGE_FIND_VERSION} VERSION_LESS ${GLM_VERSION}) + set(PACKAGE_VERSION_COMPATIBLE 1) + endif() + if(${PACKAGE_FIND_VERSION} VERSION_EQUAL ${GLM_VERSION}) + set(PACKAGE_VERSION_EXACT 1) + endif() +else() + set(PACKAGE_VERSION_UNSUITABLE 1) +endif() + diff --git a/glmConfig.cmake b/glmConfig.cmake new file mode 100644 index 00000000..75d854e0 --- /dev/null +++ b/glmConfig.cmake @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +cmake_policy(VERSION 3.2) + +set(GLM_VERSION 0.9.9) +# Set the old GLM_INCLUDE_DIRS variable for backwards compatibility +set(GLM_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}) + +add_library(glm::glm INTERFACE IMPORTED) +set_target_properties(glm::glm PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}) + +mark_as_advanced(glm_DIR) + diff --git a/manual.md b/manual.md index 15d8120a..e641a215 100644 --- a/manual.md +++ b/manual.md @@ -14,6 +14,7 @@ + [1.2. Using separated headers](#section1_2) + [1.3. Using extension headers](#section1_3) + [1.4. Dependencies](#section1_4) ++ [1.5. Finding GLM with CMake](#section1_5) + [2. Preprocessor configurations](#section2) + [2.1. GLM\_FORCE\_MESSAGES: Platform auto detection and default configuration](#section2_1) + [2.2. GLM\_FORCE\_PLATFORM\_UNKNOWN: Force GLM to no detect the build platform](#section2_2) @@ -273,6 +274,10 @@ glm::mat4 transform(glm::vec2 const& Orientation, glm::vec3 const& Translate, gl GLM does not depend on external libraries or headers such as ``, [``](http://www.opengl.org/registry/api/GL/glcorearb.h), ``, ``, or ``. +### 1.5. Finding GLM with CMake + +GLM packages a `glmConfig.cmake` and `glmConfig-version.cmake` in the root of the repository and the release archives. To find GLM with CMake you can pass `-Dglm_DIR=` when running CMake. You can then either add `${GLM_INCLUDE_DIRS}` to your target's include directories, or link against the imported `glm::glm` target. + ---
diff --git a/test/cmake/CMakeLists.txt b/test/cmake/CMakeLists.txt new file mode 100644 index 00000000..5bc11ef4 --- /dev/null +++ b/test/cmake/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +project(test_find_glm) + +find_package(glm REQUIRED) + +add_executable(test_find_glm test_find_glm.cpp) +target_link_libraries(test_find_glm glm::glm) + diff --git a/test/cmake/test_find_glm.cpp b/test/cmake/test_find_glm.cpp new file mode 100644 index 00000000..361b9777 --- /dev/null +++ b/test/cmake/test_find_glm.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +glm::mat4 camera(float Translate, glm::vec2 const& Rotate) +{ + glm::mat4 Projection = glm::perspective(glm::pi() * 0.25f, 4.0f / 3.0f, 0.1f, 100.f); + glm::mat4 View = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); + View = glm::rotate(View, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); + View = glm::rotate(View, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); + glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); + return Projection * View * Model; +} + +int main() +{ + const glm::mat4 m = camera(1.f, glm::vec2(1.f, 0.5f)); + std::cout << "matrix diagonal: " << m[0][0] << ", " + << m[1][1] << ", " << m[2][2] << ", " << m[3][3] << "\n"; + return 0; +} + From 224433b9ae37ec9eb317157fe86ed1c4f2d214a2 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Fri, 1 Nov 2019 11:16:31 -0600 Subject: [PATCH 2/7] Add a CMake Package config - Also fix clang 7 use on travis CI --- .appveyor.yml | 6 ++ .gitignore | 3 + .travis.yml | 195 ++++++++++++++++++++++++++++++++++- glmConfig-version.cmake | 13 +++ glmConfig.cmake | 13 +++ manual.md | 5 + test/cmake/CMakeLists.txt | 8 ++ test/cmake/test_find_glm.cpp | 22 ++++ 8 files changed, 260 insertions(+), 5 deletions(-) create mode 100644 glmConfig-version.cmake create mode 100644 glmConfig.cmake create mode 100644 test/cmake/CMakeLists.txt create mode 100644 test/cmake/test_find_glm.cpp diff --git a/.appveyor.yml b/.appveyor.yml index 5b018cd0..9912ffc3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -67,5 +67,11 @@ build_script: test_script: - ctest -j4 -C %CONFIGURATION% + - cd .. + - ps: | + mkdir build_test_cmake + cd build_test_cmake + cmake ..\test\cmake\ -G "$env:generator" -Dglm_DIR="$env:APPVEYOR_BUILD_FOLDER" + - cmake --build . --config %CONFIGURATION% -- /m /v:minimal deploy: off diff --git a/.gitignore b/.gitignore index a0a1fc88..9dbd6d8c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,8 @@ CMakeFiles cmake_install.cmake install_manifest.txt *.cmake +!glmConfig.cmake +!glmConfig-version.cmake # ^ May need to add future .cmake files as exceptions # Test logs @@ -56,3 +58,4 @@ build* /.vscode /CMakeSettings.json .DS_Store +*.swp diff --git a/.travis.yml b/.travis.yml index 737f7560..b0d22497 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_DISABLE_AUTO_DETECTION=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++unknown-release" @@ -23,6 +28,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++98-pure-release" @@ -35,6 +45,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++98-pure-ms-release" @@ -47,6 +62,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++11-pure-release" @@ -59,6 +79,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE2=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++11-sse2-release" @@ -71,6 +96,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++14-pure-release" @@ -83,6 +113,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++14-sse3-release" @@ -95,6 +130,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++14-avx-release" @@ -107,6 +147,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++14-avx-debug" @@ -119,6 +164,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++17-pure-release" @@ -131,6 +181,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++17-pure-debug" @@ -143,6 +198,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++17-avx-release" @@ -155,6 +215,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . env: - MATRIX_EVAL="INFO=C++17-avx-debug" @@ -174,6 +239,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -191,6 +261,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -208,6 +283,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_98=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -225,6 +305,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -242,6 +327,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -259,6 +349,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -276,6 +371,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_11=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -293,6 +393,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -310,6 +415,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -327,6 +437,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -344,6 +459,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -361,6 +481,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -378,6 +503,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE2=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -395,6 +525,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -412,6 +547,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -429,6 +569,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX2=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -447,6 +592,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -465,6 +615,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux addons: @@ -483,11 +638,16 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_14=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_AVX=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic env: - - MATRIX_EVAL="CC=clang-7.0 && INFO=C++17-pure-release" + - MATRIX_EVAL="CC=clang && CXX=clang++ && INFO=C++17-pure-release" script: - cmake --version - mkdir ./build_pure_17_release @@ -495,11 +655,16 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic env: - - MATRIX_EVAL="CC=clang-7.0 && INFO=C++17-pure-debug" + - MATRIX_EVAL="CC=clang && CXX=clang++ && INFO=C++17-pure-debug" script: - cmake --version - mkdir ./build_pure_17_debug @@ -507,11 +672,16 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_FORCE_PURE=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic env: - - MATRIX_EVAL="CC=clang-7.0 && INFO=C++17-sse3-release" + - MATRIX_EVAL="CC=clang && CXX=clang++ && INFO=C++17-sse3-release script: - cmake --version - mkdir ./build_sse3_17_release @@ -519,11 +689,16 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic env: - - MATRIX_EVAL="CC=clang-7.0 && INFO=C++17-sse3-debug" + - MATRIX_EVAL="CC=clang && CXX=clang++ && INFO=C++17-sse3-debug" script: - cmake --version - mkdir ./build_sse3_17_debug @@ -531,11 +706,16 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Debug -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . - os: linux dist: bionic env: - - MATRIX_EVAL="CC=clang-7.0 && INFO=C++17-ssse3-release" + - MATRIX_EVAL="CC=clang && CXX=clang++ && INFO=C++17-ssse3-release" script: - cmake --version - mkdir ./build_ssse3_17_release @@ -543,6 +723,11 @@ matrix: - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=Release -DGLM_TEST_ENABLE=ON -DGLM_TEST_ENABLE_CXX_17=ON -DGLM_TEST_ENABLE_LANG_EXTENSIONS=ON -DGLM_TEST_ENABLE_SIMD_SSSE3=ON .. - cmake -E time cmake --build . - ctest + - cd $TRAVIS_BUILD_DIR + - mkdir ./build_test_cmake + - cd ./build_test_cmake + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake --build . before_install: - eval "${MATRIX_EVAL}" diff --git a/glmConfig-version.cmake b/glmConfig-version.cmake new file mode 100644 index 00000000..69837ee6 --- /dev/null +++ b/glmConfig-version.cmake @@ -0,0 +1,13 @@ +set(PACKAGE_VERSION 0.9.9) + +if(${PACKAGE_FIND_VERSION_MAJOR} EQUAL 0) + if (${PACKAGE_FIND_VERSION} VERSION_LESS ${GLM_VERSION}) + set(PACKAGE_VERSION_COMPATIBLE 1) + endif() + if(${PACKAGE_FIND_VERSION} VERSION_EQUAL ${GLM_VERSION}) + set(PACKAGE_VERSION_EXACT 1) + endif() +else() + set(PACKAGE_VERSION_UNSUITABLE 1) +endif() + diff --git a/glmConfig.cmake b/glmConfig.cmake new file mode 100644 index 00000000..75d854e0 --- /dev/null +++ b/glmConfig.cmake @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +cmake_policy(VERSION 3.2) + +set(GLM_VERSION 0.9.9) +# Set the old GLM_INCLUDE_DIRS variable for backwards compatibility +set(GLM_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}) + +add_library(glm::glm INTERFACE IMPORTED) +set_target_properties(glm::glm PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}) + +mark_as_advanced(glm_DIR) + diff --git a/manual.md b/manual.md index 15d8120a..e641a215 100644 --- a/manual.md +++ b/manual.md @@ -14,6 +14,7 @@ + [1.2. Using separated headers](#section1_2) + [1.3. Using extension headers](#section1_3) + [1.4. Dependencies](#section1_4) ++ [1.5. Finding GLM with CMake](#section1_5) + [2. Preprocessor configurations](#section2) + [2.1. GLM\_FORCE\_MESSAGES: Platform auto detection and default configuration](#section2_1) + [2.2. GLM\_FORCE\_PLATFORM\_UNKNOWN: Force GLM to no detect the build platform](#section2_2) @@ -273,6 +274,10 @@ glm::mat4 transform(glm::vec2 const& Orientation, glm::vec3 const& Translate, gl GLM does not depend on external libraries or headers such as ``, [``](http://www.opengl.org/registry/api/GL/glcorearb.h), ``, ``, or ``. +### 1.5. Finding GLM with CMake + +GLM packages a `glmConfig.cmake` and `glmConfig-version.cmake` in the root of the repository and the release archives. To find GLM with CMake you can pass `-Dglm_DIR=` when running CMake. You can then either add `${GLM_INCLUDE_DIRS}` to your target's include directories, or link against the imported `glm::glm` target. + ---
diff --git a/test/cmake/CMakeLists.txt b/test/cmake/CMakeLists.txt new file mode 100644 index 00000000..5bc11ef4 --- /dev/null +++ b/test/cmake/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +project(test_find_glm) + +find_package(glm REQUIRED) + +add_executable(test_find_glm test_find_glm.cpp) +target_link_libraries(test_find_glm glm::glm) + diff --git a/test/cmake/test_find_glm.cpp b/test/cmake/test_find_glm.cpp new file mode 100644 index 00000000..361b9777 --- /dev/null +++ b/test/cmake/test_find_glm.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +glm::mat4 camera(float Translate, glm::vec2 const& Rotate) +{ + glm::mat4 Projection = glm::perspective(glm::pi() * 0.25f, 4.0f / 3.0f, 0.1f, 100.f); + glm::mat4 View = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); + View = glm::rotate(View, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); + View = glm::rotate(View, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); + glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); + return Projection * View * Model; +} + +int main() +{ + const glm::mat4 m = camera(1.f, glm::vec2(1.f, 0.5f)); + std::cout << "matrix diagonal: " << m[0][0] << ", " + << m[1][1] << ", " << m[2][2] << ", " << m[3][3] << "\n"; + return 0; +} + From 4d47b273339dd30e93ad7d7655b4f075e85337d1 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Sun, 16 Feb 2020 14:33:59 -0800 Subject: [PATCH 3/7] Adjust cmake file paths to match make install for distribution --- .../glm/glmConfig-version.cmake | 0 cmake/glm/glmConfig.cmake | 22 +++++++++++++++++++ glmConfig.cmake | 13 ----------- 3 files changed, 22 insertions(+), 13 deletions(-) rename glmConfig-version.cmake => cmake/glm/glmConfig-version.cmake (100%) create mode 100644 cmake/glm/glmConfig.cmake delete mode 100644 glmConfig.cmake diff --git a/glmConfig-version.cmake b/cmake/glm/glmConfig-version.cmake similarity index 100% rename from glmConfig-version.cmake rename to cmake/glm/glmConfig-version.cmake diff --git a/cmake/glm/glmConfig.cmake b/cmake/glm/glmConfig.cmake new file mode 100644 index 00000000..4fba5116 --- /dev/null +++ b/cmake/glm/glmConfig.cmake @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +cmake_policy(VERSION 3.2) + +set(GLM_VERSION 0.9.9) + +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if (_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Set the old GLM_INCLUDE_DIRS variable for backwards compatibility +set(GLM_INCLUDE_DIRS ${_IMPORT_PREFIX}) + +add_library(glm::glm INTERFACE IMPORTED) +set_target_properties(glm::glm PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${GLM_INCLUDE_DIRS}) + +mark_as_advanced(glm_DIR) +set(_IMPORT_PREFIX) + diff --git a/glmConfig.cmake b/glmConfig.cmake deleted file mode 100644 index 75d854e0..00000000 --- a/glmConfig.cmake +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.2 FATAL_ERROR) -cmake_policy(VERSION 3.2) - -set(GLM_VERSION 0.9.9) -# Set the old GLM_INCLUDE_DIRS variable for backwards compatibility -set(GLM_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}) - -add_library(glm::glm INTERFACE IMPORTED) -set_target_properties(glm::glm PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}) - -mark_as_advanced(glm_DIR) - From 681b8badcd4c6fc7be56925d24a688ac6cabf15b Mon Sep 17 00:00:00 2001 From: Will Usher Date: Sun, 16 Feb 2020 14:37:37 -0800 Subject: [PATCH 4/7] Fix appveyor glm_DIR path --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index e8006f3d..f82b848e 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -81,7 +81,7 @@ test_script: - ps: | mkdir build_test_cmake cd build_test_cmake - cmake ..\test\cmake\ -G "$env:generator" -Dglm_DIR="$env:APPVEYOR_BUILD_FOLDER" + cmake ..\test\cmake\ -G "$env:generator" -Dglm_DIR="$env:APPVEYOR_BUILD_FOLDER/cmake/glm/" - cmake --build . --config %CONFIGURATION% -- /m /v:minimal deploy: off From e6af4467165f1ccd6d5c02b6d58380e99ae3a359 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Sun, 16 Feb 2020 14:38:27 -0800 Subject: [PATCH 5/7] fix manual glm_DIR mention --- manual.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual.md b/manual.md index 0efd82c6..a7f6956f 100644 --- a/manual.md +++ b/manual.md @@ -277,7 +277,7 @@ GLM does not depend on external libraries or headers such as ``, [` 1.5. Finding GLM with CMake -GLM packages a `glmConfig.cmake` and `glmConfig-version.cmake` in the root of the repository and the release archives. To find GLM with CMake you can pass `-Dglm_DIR=` when running CMake. You can then either add `${GLM_INCLUDE_DIRS}` to your target's include directories, or link against the imported `glm::glm` target. +GLM packages a `glmConfig.cmake` and `glmConfig-version.cmake` in the root of the repository and the release archives. To find GLM with CMake you can pass `-Dglm_DIR=/cmake/glm/` when running CMake. You can then either add `${GLM_INCLUDE_DIRS}` to your target's include directories, or link against the imported `glm::glm` target. ---
From 739a16e6d1ac8e80a486e62d120a08216fe992b6 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Wed, 19 Feb 2020 09:10:57 -0700 Subject: [PATCH 6/7] fix travis as well --- .travis.yml | 74 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0d22497..8eae8f73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++unknown-release" @@ -31,7 +31,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++98-pure-release" @@ -48,7 +48,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++98-pure-ms-release" @@ -65,7 +65,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++11-pure-release" @@ -82,7 +82,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++11-sse2-release" @@ -99,7 +99,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++14-pure-release" @@ -116,7 +116,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++14-sse3-release" @@ -133,7 +133,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++14-avx-release" @@ -150,7 +150,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++14-avx-debug" @@ -167,7 +167,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++17-pure-release" @@ -184,7 +184,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++17-pure-debug" @@ -201,7 +201,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++17-avx-release" @@ -218,7 +218,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . env: - MATRIX_EVAL="INFO=C++17-avx-debug" @@ -242,7 +242,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -264,7 +264,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -286,7 +286,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -308,7 +308,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -330,7 +330,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -352,7 +352,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -374,7 +374,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -396,7 +396,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -418,7 +418,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -440,7 +440,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -462,7 +462,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -484,7 +484,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -506,7 +506,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -528,7 +528,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -550,7 +550,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -572,7 +572,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -595,7 +595,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -618,7 +618,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -641,7 +641,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -658,7 +658,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -675,7 +675,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -692,7 +692,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -709,7 +709,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . - os: linux @@ -726,7 +726,7 @@ matrix: - cd $TRAVIS_BUILD_DIR - mkdir ./build_test_cmake - cd ./build_test_cmake - - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR + - cmake -DCMAKE_CXX_COMPILER=$COMPILER $TRAVIS_BUILD_DIR/test/cmake/ -Dglm_DIR=$TRAVIS_BUILD_DIR/cmake/glm/ - cmake --build . before_install: From 31d01b525e13db4cbc293f22f46c9913ef07ff09 Mon Sep 17 00:00:00 2001 From: Kontny Karol Date: Thu, 14 Nov 2019 15:51:20 +0100 Subject: [PATCH 7/7] Quaternion slerp overload which interpolates with extra spins Signed-off-by: Karol Kontny --- glm/ext/quaternion_common.hpp | 15 +++++++ glm/ext/quaternion_common.inl | 37 ++++++++++++++++ test/gtc/gtc_quaternion.cpp | 79 +++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) diff --git a/glm/ext/quaternion_common.hpp b/glm/ext/quaternion_common.hpp index 2980ed4d..f519d559 100644 --- a/glm/ext/quaternion_common.hpp +++ b/glm/ext/quaternion_common.hpp @@ -76,6 +76,21 @@ namespace glm template GLM_FUNC_DECL qua slerp(qua const& x, qua const& y, T a); + /// Spherical linear interpolation of two quaternions with multiple spins over rotation axis. + /// The interpolation always take the short path when the spin count is positive and long path + /// when count is negative. Rotation is performed at constant speed. + /// + /// @param x A quaternion + /// @param y A quaternion + /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. + /// @param k Additional spin count. If Value is negative interpolation will be on "long" path. + /// + /// @tparam T A floating-point scalar type + /// @tparam S An integer scalar type + /// @tparam Q A value from qualifier enum + template + GLM_FUNC_DECL qua slerp(qua const& x, qua const& y, T a, S k); + /// Returns the q conjugate. /// /// @tparam T A floating-point scalar type diff --git a/glm/ext/quaternion_common.inl b/glm/ext/quaternion_common.inl index 3b2846f3..0e4a3bb2 100644 --- a/glm/ext/quaternion_common.inl +++ b/glm/ext/quaternion_common.inl @@ -72,6 +72,43 @@ namespace glm } } + template + GLM_FUNC_QUALIFIER qua slerp(qua const& x, qua const& y, T a, S k) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'slerp' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'slerp' only accept integer for spin count"); + + qua z = y; + + T cosTheta = dot(x, y); + + // If cosTheta < 0, the interpolation will take the long way around the sphere. + // To fix this, one quat must be negated. + if (cosTheta < static_cast(0)) + { + z = -y; + cosTheta = -cosTheta; + } + + // Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator + if (cosTheta > static_cast(1) - epsilon()) + { + // Linear interpolation + return qua( + mix(x.w, z.w, a), + mix(x.x, z.x, a), + mix(x.y, z.y, a), + mix(x.z, z.z, a)); + } + else + { + // Graphics Gems III, page 96 + T angle = acos(cosTheta); + T phi = angle + k * glm::pi(); + return (sin(angle - a * phi)* x + sin(a * phi) * z) / sin(angle); + } + } + template GLM_FUNC_QUALIFIER qua conjugate(qua const& q) { diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 65f3b44a..540ca42d 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -194,6 +194,84 @@ int test_quat_slerp() return Error; } +int test_quat_slerp_spins() +{ + int Error = 0; + + float const Epsilon = 0.0001f;//glm::epsilon(); + + float sqrt2 = std::sqrt(2.0f) / 2.0f; + glm::quat id(static_cast(1), static_cast(0), static_cast(0), static_cast(0)); + glm::quat Y90rot(sqrt2, 0.0f, sqrt2, 0.0f); + glm::quat Y180rot(0.0f, 0.0f, 1.0f, 0.0f); + + // Testing a == 0, k == 1 + // Must be id + glm::quat id2 = glm::slerp(id, id, 1.0f, 1); + Error += glm::all(glm::equal(id, id2, Epsilon)) ? 0 : 1; + + // Testing a == 1, k == 2 + // Must be id + glm::quat id3 = glm::slerp(id, id, 1.0f, 2); + Error += glm::all(glm::equal(id, id3, Epsilon)) ? 0 : 1; + + // Testing a == 1, k == 1 + // Must be 90° rotation on Y : 0 0.7 0 0.7 + // Negative quaternion is representing same orientation + glm::quat Y90rot2 = glm::slerp(id, Y90rot, 1.0f, 1); + Error += glm::all(glm::equal(Y90rot, -Y90rot2, Epsilon)) ? 0 : 1; + + // Testing a == 1, k == 2 + // Must be id + glm::quat Y90rot3 = glm::slerp(id, Y90rot, 8.0f / 9.0f, 2); + Error += glm::all(glm::equal(id, Y90rot3, Epsilon)) ? 0 : 1; + + // Testing a == 1, k == 1 + // Must be 90° rotation on Y : 0 0.7 0 0.7 + glm::quat Y90rot4 = glm::slerp(id, Y90rot, 0.2f, 1); + Error += glm::all(glm::equal(Y90rot, Y90rot4, Epsilon)) ? 0 : 1; + + // Testing reverse case + // Must be 45° rotation on Y : 0 0.38 0 0.92 + // Negative quaternion is representing same orientation + glm::quat Ym45rot2 = glm::slerp(Y90rot, id, 0.9f, 1); + glm::quat Ym45rot3 = glm::slerp(Y90rot, id, 0.5f); + Error += glm::all(glm::equal(-Ym45rot2, Ym45rot3, Epsilon)) ? 0 : 1; + + // Testing against full circle around the sphere instead of shortest path + // Must be 45° rotation on Y + // certainly not a 135° rotation + glm::quat Y45rot3 = glm::slerp(id, -Y90rot, 0.5f, 0); + float Y45angle3 = glm::angle(Y45rot3); + Error += glm::equal(Y45angle3, glm::pi() * 0.25f, Epsilon) ? 0 : 1; + Error += glm::all(glm::equal(Ym45rot3, Y45rot3, Epsilon)) ? 0 : 1; + + // Same, but inverted + // Must also be 45° rotation on Y : 0 0.38 0 0.92 + // -0 -0.38 -0 -0.92 is ok too + glm::quat Y45rot4 = glm::slerp(-Y90rot, id, 0.5f, 0); + Error += glm::all(glm::equal(Ym45rot2, Y45rot4, Epsilon)) ? 0 : 1; + + // Testing q1 = q2 k == 2 + // Must be 90° rotation on Y : 0 0.7 0 0.7 + glm::quat Y90rot5 = glm::slerp(Y90rot, Y90rot, 0.5f, 2); + Error += glm::all(glm::equal(Y90rot, Y90rot5, Epsilon)) ? 0 : 1; + + // Testing 180° rotation + // Must be 90° rotation on almost any axis that is on the XZ plane + glm::quat XZ90rot = glm::slerp(id, -Y90rot, 0.5f, 1); + float XZ90angle = glm::angle(XZ90rot); // Must be PI/4 = 0.78; + Error += glm::equal(XZ90angle, glm::pi() * 1.25f, Epsilon) ? 0 : 1; + + // Testing rotation over long arc + // Distance from id to 90° is 270°, so 2/3 of it should be 180° + // Negative quaternion is representing same orientation + glm::quat Neg90rot = glm::slerp(id, Y90rot, 2.0f / 3.0f, -1); + Error += glm::all(glm::equal(Y180rot, -Neg90rot, Epsilon)) ? 0 : 1; + + return Error; +} + static int test_quat_mul_vec() { int Error(0); @@ -260,6 +338,7 @@ int main() Error += test_quat_normalize(); Error += test_quat_euler(); Error += test_quat_slerp(); + Error += test_quat_slerp_spins(); Error += test_identity(); return Error;