cmake_minimum_required(VERSION 3.8.2) project(cglm VERSION 0.7.8 LANGUAGES C) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED YES) set(DEFAULT_BUILD_TYPE "Release") set(CGLM_BUILD) option(CGLM_SHARED "Shared build" ON) option(CGLM_STATIC "Static build" OFF) option(CGLM_USE_C99 "" OFF) option(CGLM_USE_TEST "Enable Tests" OFF) if(NOT CGLM_STATIC AND CGLM_SHARED) set(CGLM_BUILD SHARED) else(CGLM_STATIC) set(CGLM_BUILD STATIC) endif() if(CGLM_USE_C99) set(C_STANDARD 99) endif() if(MSVC) add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL) add_compile_options(/W3 /Ox /Gy /Oi /TC) # Ref: https://skia.googlesource.com/third_party/sdl/+/refs/heads/master/CMakeLists.txt#225 # Make sure /RTC1 is disabled, otherwise it will use functions from the CRT foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}") endforeach(flag_var) else() add_compile_options(-Wall -Werror -O3) endif() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.") set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() include(GNUInstallDirs) set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) include(CPack) # Target Start add_library(${PROJECT_NAME} ${CGLM_BUILD} src/euler.c src/affine.c src/io.c src/quat.c src/cam.c src/vec2.c src/vec3.c src/vec4.c src/mat2.c src/mat3.c src/mat4.c src/plane.c src/frustum.c src/box.c src/project.c src/sphere.c src/ease.c src/curve.c src/bezier.c src/ray.c src/affine2d.c ) if(CGLM_SHARED) add_definitions(-DCGLM_EXPORTS) else() target_compile_definitions(${PROJECT_NAME} PUBLIC -DCGLM_STATIC) endif() set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) target_include_directories(${PROJECT_NAME} PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) # Test Configuration if(CGLM_USE_TEST) include(CTest) enable_testing() add_subdirectory(test) endif() # Install install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(DIRECTORY include/${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PATTERN ".*" EXCLUDE) # Config export(TARGETS ${PROJECT_NAME} NAMESPACE ${PROJECT_NAME}:: FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" ) install(EXPORT ${PROJECT_NAME} NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake)