CMakeLists.txt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
  2. # When turning this option on, the library will be compiled using doubles for positions. This allows for much bigger worlds.
  3. option(DOUBLE_PRECISION "Use double precision math" OFF)
  4. # Number of bits to use in ObjectLayer. Can be 16 or 32.
  5. option(OBJECT_LAYER_BITS "Number of bits in ObjectLayer" 16)
  6. include(CMakeDependentOption)
  7. # Ability to toggle between the static and DLL versions of the MSVC runtime library
  8. # Windows Store only supports the DLL version
  9. cmake_dependent_option(USE_STATIC_MSVC_RUNTIME_LIBRARY "Use the static MSVC runtime library" ON "MSVC;NOT WINDOWS_STORE" OFF)
  10. if (USE_STATIC_MSVC_RUNTIME_LIBRARY)
  11. set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
  12. endif()
  13. # Only do this when we're at the top level, see: https://gitlab.kitware.com/cmake/cmake/-/issues/24181
  14. if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
  15. set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
  16. endif()
  17. project(JoltC VERSION 0.1
  18. DESCRIPTION "C Wrapper for Jolt Physics"
  19. LANGUAGES C CXX)
  20. add_library(joltc STATIC
  21. JoltC/JoltC.h
  22. JoltC/JoltC.cpp
  23. JoltC/Enums.h
  24. JoltC/Functions.h
  25. JoltC/Test.cpp
  26. )
  27. target_compile_features(joltc PUBLIC cxx_std_17)
  28. target_include_directories(joltc PUBLIC . JoltPhysics)
  29. target_link_libraries(joltc PUBLIC Jolt)
  30. install(TARGETS joltc DESTINATION lib)
  31. if(MSVC)
  32. target_compile_options(joltc PRIVATE /W4)
  33. # Ignore 'unreferenced function with internal linkage'
  34. target_compile_options(joltc PRIVATE /wd4505)
  35. else()
  36. target_compile_options(joltc PRIVATE -Wall -Wextra -Wpedantic)
  37. endif()
  38. if (DOUBLE_PRECISION)
  39. target_compile_definitions(joltc PUBLIC JPC_DOUBLE_PRECISION)
  40. endif()
  41. if (OBJECT_LAYER_BITS)
  42. target_compile_definitions(joltc PUBLIC JPC_OBJECT_LAYER_BITS=${OBJECT_LAYER_BITS})
  43. endif()
  44. if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
  45. add_executable(HelloWorld
  46. HelloWorld/main.cpp
  47. )
  48. # cxx_std_20 gives us designated initializers, bringing us closer to Actual C.
  49. target_compile_features(HelloWorld PRIVATE cxx_std_20)
  50. # Eventually we should switch back to Actual C:
  51. # set_property(TARGET HelloWorld PROPERTY C_STANDARD 23)
  52. target_include_directories(HelloWorld PUBLIC .)
  53. target_link_libraries(HelloWorld PUBLIC joltc)
  54. endif()
  55. add_subdirectory(JoltPhysics/Build)