CMakeLists.txt 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright (c) 2008-2020 the Urho3D project.
  2. #
  3. # Permission is hereby granted, free of charge, to any person obtaining a copy
  4. # of this software and associated documentation files (the "Software"), to deal
  5. # in the Software without restriction, including without limitation the rights
  6. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. # copies of the Software, and to permit persons to whom the Software is
  8. # furnished to do so, subject to the following conditions:
  9. #
  10. # The above copyright notice and this permission notice shall be included in
  11. # all copies or substantial portions of the Software.
  12. #
  13. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. # THE SOFTWARE.
  20. #
  21. include (CheckIncludeFiles)
  22. # Define target name
  23. set (TARGET_NAME ik)
  24. check_include_files (stdint.h IK_HAVE_STDINT_H)
  25. 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)
  26. 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)
  27. # Need to set IK_PLATFORM for dllimport/dllexport
  28. if (WIN32)
  29. set (IK_PLATFORM "WINDOWS")
  30. elseif (APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  31. set (IK_PLATFORM "OSX")
  32. elseif (IOS)
  33. set (IK_PLATFORM "IOS")
  34. elseif (UNIX)
  35. set (IK_PLATFORM "LINUX")
  36. else ()
  37. set (IK_PLATFORM "ANDROID")
  38. endif ()
  39. # Enable restrict keyword in quaternion and vector operations if not in debug
  40. # Only do this if IK_RESTRICT is not cached yet.
  41. get_cmake_property (CACHED_VARS VARIABLES)
  42. list (FIND CACHED_VARS "IK_RESTRICT" RESULT)
  43. if (${RESULT} MATCHES -1)
  44. foreach (RESTRICT_KEYWORD restrict __restrict __restrict__)
  45. check_c_source_compiles ("int test (void *${RESTRICT_KEYWORD} x); int main (void) {return 0;}" IK_RESTRICT_${RESTRICT_KEYWORD})
  46. if (IK_RESTRICT_${RESTRICT_KEYWORD})
  47. set (IK_RESTRICT ${RESTRICT_KEYWORD})
  48. break ()
  49. endif ()
  50. endforeach ()
  51. set (IK_RESTRICT ${IK_RESTRICT} CACHE STRING "Restrict Keyword (may be empty)")
  52. endif ()
  53. set (IK_REAL float CACHE STRING "Type to use for real numbers")
  54. option (IK_DOT_OUTPUT "When enabled, the generated chains are dumped to DOT for debug purposes" OFF)
  55. # Define source files
  56. define_source_files (GLOB_CPP_PATTERNS src/*.c GLOB_H_PATTERNS include/ik/*.h)
  57. if (IK_MEMORY_BACKTRACE)
  58. list (APPEND SOURCE_FILES src/platform/linux/backtrace_linux.c)
  59. endif ()
  60. # Define generated source files
  61. set (IK_LIB_TYPE STATIC) # Urho always builds its 3rd-party as STATIC lib
  62. configure_file (include/ik/export.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/generated/ik/export.h)
  63. configure_file (include/ik/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/generated/ik/config.h)
  64. # Define dependency libs
  65. set (INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include/generated include)
  66. # Setup target
  67. setup_library ()
  68. # Install headers for building the Urho3D library
  69. 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
  70. 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)