CMakeLists.txt 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Copyright (c) 2008-2023 the Urho3D project
  2. # License: MIT
  3. include (CheckIncludeFiles)
  4. # Define target name
  5. set (TARGET_NAME ik)
  6. check_include_files (stdint.h IK_HAVE_STDINT_H)
  7. option (IK_MEMORY_DEBUGGING "Global switch for memory options. Keep track of the number of allocations and de-allocations and prints a report when the program shuts down" FALSE)
  8. cmake_dependent_option (IK_MEMORY_BACKTRACE "Generate backtraces for every malloc(), making it easy to track down memory leaks" FALSE "IK_MEMORY_DEBUGGING AND UNIX AND NOT WEB AND NOT ANDROID" FALSE)
  9. # Need to set IK_PLATFORM for dllimport/dllexport
  10. if (WIN32)
  11. set (IK_PLATFORM "WINDOWS")
  12. elseif (APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  13. set (IK_PLATFORM "OSX")
  14. elseif (IOS)
  15. set (IK_PLATFORM "IOS")
  16. elseif (UNIX)
  17. set (IK_PLATFORM "LINUX")
  18. else ()
  19. set (IK_PLATFORM "ANDROID")
  20. endif ()
  21. # Enable restrict keyword in quaternion and vector operations if not in debug
  22. # Only do this if IK_RESTRICT is not cached yet.
  23. get_cmake_property (CACHED_VARS VARIABLES)
  24. list (FIND CACHED_VARS "IK_RESTRICT" RESULT)
  25. if (${RESULT} MATCHES -1)
  26. foreach (RESTRICT_KEYWORD restrict __restrict __restrict__)
  27. check_c_source_compiles ("int test (void *${RESTRICT_KEYWORD} x); int main (void) {return 0;}" IK_RESTRICT_${RESTRICT_KEYWORD})
  28. if (IK_RESTRICT_${RESTRICT_KEYWORD})
  29. set (IK_RESTRICT ${RESTRICT_KEYWORD})
  30. break ()
  31. endif ()
  32. endforeach ()
  33. set (IK_RESTRICT ${IK_RESTRICT} CACHE STRING "Restrict Keyword (may be empty)")
  34. endif ()
  35. set (IK_REAL float CACHE STRING "Type to use for real numbers")
  36. option (IK_DOT_OUTPUT "When enabled, the generated chains are dumped to DOT for debug purposes" OFF)
  37. # Define source files
  38. define_source_files (GLOB_CPP_PATTERNS src/*.c GLOB_H_PATTERNS include/ik/*.h)
  39. if (IK_MEMORY_BACKTRACE)
  40. list (APPEND SOURCE_FILES src/platform/linux/backtrace_linux.c)
  41. endif ()
  42. # Define generated source files
  43. set (IK_LIB_TYPE STATIC) # Urho always builds its 3rd-party as STATIC lib
  44. configure_file (include/ik/export.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/generated/ik/export.h)
  45. configure_file (include/ik/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/generated/ik/config.h)
  46. # Define dependency libs
  47. set (INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include/generated include)
  48. # Setup target
  49. setup_library ()
  50. # Install headers for building the Urho3D library
  51. install_header_files (DIRECTORY include/ik/ DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/ik FILES_MATCHING PATTERN *.h USE_FILE_SYMLINK BUILD_TREE_ONLY) # Note: the trailing slash is significant
  52. install_header_files (FILES ${CMAKE_CURRENT_BINARY_DIR}/include/generated/ik/export.h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/ik/config.h DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/ik BUILD_TREE_ONLY)