Clean up CMake project, added arithmetic operators to swizzle operators types

This commit is contained in:
Christophe Riccio 2018-07-14 19:14:08 +02:00
parent ac1f60997c
commit a23dd2f800
5 changed files with 51 additions and 82 deletions

View File

@ -11,21 +11,6 @@ include(CMakePackageConfigHelpers)
enable_testing()
option(GLM_STATIC_LIBRARY_ENABLE "GLM static library" OFF)
if(GLM_STATIC_LIBRARY_ENABLE)
message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_STATIC_LIBRARY_ENABLE with ON to build an optional static library")
endif()
option(GLM_DYNAMIC_LIBRARY_ENABLE "GLM dynamic library" OFF)
if(GLM_DYNAMIC_LIBRARY_ENABLE)
message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_DYNAMIC_LIBRARY_ENABLE with ON to build an optional dynamic library")
endif()
option(GLM_TEST_ENABLE "GLM test" OFF)
if(NOT GLM_TEST_ENABLE)
message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_TEST_ENABLE with ON to build and run the test bench")
endif()
option(GLM_TEST_ENABLE_CXX_98 "Enable C++ 98" OFF)
option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF)
option(GLM_TEST_ENABLE_CXX_14 "Enable C++ 14" OFF)
@ -177,12 +162,8 @@ include_directories("${PROJECT_SOURCE_DIR}")
add_subdirectory(glm)
add_subdirectory(test)
option(GLM_INSTALL_ENABLE "GLM install" ON)
set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm")
if (GLM_INSTALL_ENABLE)
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" VERSION ${GLM_VERSION} COMPATIBILITY AnyNewerVersion)
@ -197,12 +178,10 @@ configure_package_config_file(
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
if(GLM_INSTALL_ENABLE)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake"
DESTINATION ${GLM_INSTALL_CONFIGDIR})
endif()
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake"
DESTINATION ${GLM_INSTALL_CONFIGDIR})
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE
@ -212,17 +191,13 @@ install(TARGETS glm EXPORT glmTargets)
export(EXPORT glmTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake")
if(GLM_INSTALL_ENABLE)
install(EXPORT glmTargets FILE glmTargets.cmake DESTINATION ${GLM_INSTALL_CONFIGDIR})
endif()
install(EXPORT glmTargets FILE glmTargets.cmake DESTINATION ${GLM_INSTALL_CONFIGDIR})
# build pkg-config file
configure_file("./cmake/glm.pc.in" "glm.pc" @ONLY)
# install pkg-config file
if (GLM_INSTALL_ENABLE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
export(PACKAGE glm)

View File

@ -44,34 +44,19 @@ source_group("SIMD Files" FILES ${SIMD_HEADER})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
if(GLM_STATIC_LIBRARY_ENABLE OR GLM_DYNAMIC_LIBRARY_ENABLE)
if(GLM_STATIC_LIBRARY_ENABLE)
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
endif(GLM_STATIC_LIBRARY_ENABLE)
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
if(GLM_DYNAMIC_LIBRARY_ENABLE)
add_library(glm_shared SHARED ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
endif(GLM_DYNAMIC_LIBRARY_ENABLE)
add_library(glm_shared SHARED ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
else(GLM_STATIC_LIBRARY_ENABLE OR GLM_DYNAMIC_LIBRARY_ENABLE)
add_executable(glm_dummy ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
endif(GLM_STATIC_LIBRARY_ENABLE OR GLM_DYNAMIC_LIBRARY_ENABLE)

View File

@ -51,25 +51,24 @@ namespace glm
typename detail::storage<1, T, detail::is_aligned<Q>::value>::type data;
/*
# if GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, x)
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, r)
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, s)
_GLM_SWIZZLE1_3_MEMBERS(T, Q, tvec3, x)
_GLM_SWIZZLE1_3_MEMBERS(T, Q, tvec3, r)
_GLM_SWIZZLE1_3_MEMBERS(T, Q, tvec3, s)
_GLM_SWIZZLE1_4_MEMBERS(T, Q, tvec4, x)
_GLM_SWIZZLE1_4_MEMBERS(T, Q, tvec4, r)
_GLM_SWIZZLE1_4_MEMBERS(T, Q, tvec4, s)
_GLM_SWIZZLE1_2_MEMBERS(T, Q, x)
_GLM_SWIZZLE1_2_MEMBERS(T, Q, r)
_GLM_SWIZZLE1_2_MEMBERS(T, Q, s)
_GLM_SWIZZLE1_3_MEMBERS(T, Q, x)
_GLM_SWIZZLE1_3_MEMBERS(T, Q, r)
_GLM_SWIZZLE1_3_MEMBERS(T, Q, s)
_GLM_SWIZZLE1_4_MEMBERS(T, Q, x)
_GLM_SWIZZLE1_4_MEMBERS(T, Q, r)
_GLM_SWIZZLE1_4_MEMBERS(T, Q, s)
# endif
*/
};
# else
union {T x, r, s;};
/*
# if GLM_SWIZZLE == GLM_SWIZZLE_FUNCTION
GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, Q, tvec2, tvec2, tvec3, tvec4)
GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, Q)
# endif
*/
# endif
// -- Component accesses --
@ -112,7 +111,7 @@ namespace glm
/*
# if GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR
template<int E0>
GLM_FUNC_DECL tvec(detail::_swizzle<1, T, Q, tvec1, E0, -1,-2,-3> const& that)
GLM_FUNC_DECL tvec(detail::_swizzle<1, T, Q, E0, -1,-2,-3> const& that)
{
*this = that();
}

View File

@ -1,12 +1,10 @@
function(glmCreateTestGTC NAME)
if(GLM_TEST_ENABLE)
set(SAMPLE_NAME test-${NAME})
add_executable(${SAMPLE_NAME} ${NAME}.cpp)
set(SAMPLE_NAME test-${NAME})
add_executable(${SAMPLE_NAME} ${NAME}.cpp)
add_test(
NAME ${SAMPLE_NAME}
COMMAND $<TARGET_FILE:${SAMPLE_NAME}> )
endif(GLM_TEST_ENABLE)
add_test(
NAME ${SAMPLE_NAME}
COMMAND $<TARGET_FILE:${SAMPLE_NAME}> )
endfunction()
add_subdirectory(bug)

View File

@ -60,7 +60,7 @@ int test_ivec3_swizzle()
# if GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR
{
glm::ivec3 A(1, 2, 3);
glm::ivec3 const A(1, 2, 3);
glm::ivec2 B = A.yx;
glm::ivec2 C = A.yx;
@ -82,6 +82,18 @@ int test_ivec3_swizzle()
Error += E == A.xy() ? 0 : 1;
Error += E.xy() == A.xy() ? 0 : 1;
glm::ivec3 const F = A.xxx + A.xxx;
Error += F == glm::ivec3(2) ? 0 : 1;
glm::ivec3 const G = A.xxx - A.xxx;
Error += G == glm::ivec3(0) ? 0 : 1;
glm::ivec3 const H = A.xxx * A.xxx;
Error += H == glm::ivec3(1) ? 0 : 1;
glm::ivec3 const I = A.xxx / A.xxx;
Error += I == glm::ivec3(1) ? 0 : 1;
}
# endif//GLM_SWIZZLE