CMakeLists.txt 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright (c) 2008-2017 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. # Memory debugging options, non-DEBUG and multi-config generator will set the default to FALSE
  26. if (CMAKE_BUILD_TYPE STREQUAL Debug)
  27. set (DEFAULT_MEMORY_DEBUGGING 1)
  28. endif ()
  29. 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" ${DEFAULT_MEMORY_DEBUGGING})
  30. cmake_dependent_option (IK_MEMORY_BACKTRACE "Generate backtraces for every malloc(), making it easy to track down memory leaks" "${DEFAULT_MEMORY_DEBUGGING}" "IK_MEMORY_DEBUGGING AND UNIX AND NOT WEB" FALSE)
  31. # Need to set IK_PLATFORM for dllimport/dllexport
  32. if (WIN32)
  33. set (IK_PLATFORM "WINDOWS")
  34. elseif (APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  35. set (IK_PLATFORM "OSX")
  36. elseif (IOS)
  37. set (IK_PLATFORM "IOS")
  38. elseif (UNIX)
  39. set (IK_PLATFORM "LINUX")
  40. else ()
  41. set (IK_PLATFORM "ANDROID")
  42. endif ()
  43. # Enable restrict keyword in quaternion and vector operations if not in debug
  44. # Only do this if IK_RESTRICT is not cached yet.
  45. get_cmake_property (CACHED_VARS VARIABLES)
  46. list (FIND CACHED_VARS "IK_RESTRICT" RESULT)
  47. if (${RESULT} MATCHES -1)
  48. foreach (RESTRICT_KEYWORD restrict __restrict __restrict__)
  49. check_c_source_compiles ("int test (void *${RESTRICT_KEYWORD} x); int main (void) {return 0;}" IK_RESTRICT_${RESTRICT_KEYWORD})
  50. if (IK_RESTRICT_${RESTRICT_KEYWORD})
  51. set (IK_RESTRICT ${RESTRICT_KEYWORD})
  52. break ()
  53. endif ()
  54. endforeach ()
  55. set (IK_RESTRICT ${IK_RESTRICT} CACHE STRING "Restrict Keyword (may be empty)")
  56. endif ()
  57. set (IK_REAL float CACHE STRING "Type to use for real numbers")
  58. option (IK_DOT_OUTPUT "When enabled, the generated chains are dumped to DOT for debug purposes" OFF)
  59. # Define source files
  60. define_source_files (GLOB_CPP_PATTERNS src/*.c GLOB_H_PATTERNS include/ik/*.h)
  61. if (IK_MEMORY_BACKTRACE)
  62. list (APPEND SOURCE_FILES src/platform/linux/backtrace_linux.c)
  63. endif ()
  64. # Define generated source files
  65. set (IK_LIB_TYPE STATIC) # Urho always builds its 3rd-party as STATIC lib
  66. configure_file (include/ik/export.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/generated/ik/export.h)
  67. configure_file (include/ik/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/generated/ik/config.h)
  68. # Define dependency libs
  69. set (INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include/generated include)
  70. # Setup target
  71. setup_library ()