From c81eb93b6d008b4bbf09df6ead11a4109c5fd105 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 11 Jun 2019 16:04:52 -1000 Subject: [PATCH] Better CMake dependency handling --- CMakeLists.txt | 11 ++++++----- include/zeus/CQuaternion.hpp | 6 ++++-- include/zeus/simd/simd_sse.hpp | 6 ++++-- src/CQuaternion.cpp | 6 ------ test/CMakeLists.txt | 2 -- test/main.cpp | 2 ++ 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7497a4..352e5f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,6 @@ project(zeus) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -if (NOT DEFINED ATHENA_INCLUDE_DIR) - set(ATHENA_INCLUDE_DIR ../athena/include) -endif() -include_directories(include ${ATHENA_INCLUDE_DIR}) - set(SOURCES src/CVector3f.cpp src/Math.cpp @@ -59,5 +54,11 @@ add_library(zeus include/zeus/simd/simd_avx.hpp include/zeus/simd/parallelism_v2_simd.hpp) +target_include_directories(zeus PUBLIC $) +if(TARGET athena-core) + target_link_libraries(zeus PUBLIC athena-core) + target_compile_definitions(zeus PUBLIC ZE_ATHENA_TYPES=1) +endif() + add_subdirectory(test) diff --git a/include/zeus/CQuaternion.hpp b/include/zeus/CQuaternion.hpp index 5ab09de..feaa7c3 100644 --- a/include/zeus/CQuaternion.hpp +++ b/include/zeus/CQuaternion.hpp @@ -101,9 +101,11 @@ public: CQuaternion normalized() const { return *this / magnitude(); } - void invert(); + static constexpr simd InvertQuat = {1.f, -1.f, -1.f, -1.f}; - CQuaternion inverse() const; + void invert() { mSimd *= InvertQuat; } + + CQuaternion inverse() const { return mSimd * InvertQuat; } /** * @brief Set the rotation using axis angle notation diff --git a/include/zeus/simd/simd_sse.hpp b/include/zeus/simd/simd_sse.hpp index 252ce93..a465a52 100644 --- a/include/zeus/simd/simd_sse.hpp +++ b/include/zeus/simd/simd_sse.hpp @@ -221,12 +221,14 @@ public: sse_data[__index % 2] = __val; __storage_[__index / 2] = _mm_load_pd(sse_data.data()); } - constexpr __simd_storage(double a, double b, double c, double d) : __storage_{__m128d{a, b}, __m128d{c, d}} {} + static constexpr storage_type __make_array(__m128d a, __m128d b) { return {a, b}; } + constexpr __simd_storage(double a, double b, double c, double d) + : __storage_(__make_array(__m128d{a, b}, __m128d{c, d})) {} void __set4(double a, double b, double c, double d) noexcept { __storage_[0] = _mm_set_pd(b, a); __storage_[1] = _mm_set_pd(d, c); } - constexpr __simd_storage(double rv) : __storage_{__m128d{rv, rv}, __m128d{rv, rv}} {} + constexpr __simd_storage(double rv) : __storage_(__make_array(__m128d{rv, rv}, __m128d{rv, rv})) {} void __broadcast(double __val) noexcept { for (int i = 0; i < 2; ++i) __storage_[i] = _mm_set1_pd(__val); diff --git a/src/CQuaternion.cpp b/src/CQuaternion.cpp index 91b6ecb..5e4839b 100644 --- a/src/CQuaternion.cpp +++ b/src/CQuaternion.cpp @@ -149,12 +149,6 @@ const CQuaternion& CQuaternion::operator/=(float scale) { return *this; } -static const simd InvertQuat(1.f, -1.f, -1.f, -1.f); - -void CQuaternion::invert() { mSimd *= InvertQuat; } - -CQuaternion CQuaternion::inverse() const { return mSimd * InvertQuat; } - CQuaternion CQuaternion::log() const { float a = std::acos(w()); float sina = std::sin(a); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d0aaade..9409c7f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,5 @@ project(zeustest) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -include_directories(../include) - add_executable(zeustest main.cpp) target_link_libraries(zeustest zeus) diff --git a/test/main.cpp b/test/main.cpp index 8301e37..b621aad 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -12,6 +12,8 @@ union Color { zeus::Comp32 rgba; }; +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" + int main() { zeus::detectCPU(); assert(!CAABox({100, 100, 100}, {100, 100, 100}).invalid());