CMakeLists.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #
  2. # SuperTux - squirrel library build script
  3. # Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. SET(CMAKE_MACOSX_RPATH ON)
  20. ## Apply patch that fixes some Coverity errors
  21. ## Apply coverity patch to Squirrel?
  22. SET(APPLY_COVERITY_PATCH FALSE)
  23. SET(WORKING_DIR WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
  24. IF(APPLY_COVERITY_PATCH)
  25. FIND_PROGRAM(PATCH_EXECUTABLE patch)
  26. IF(PATCH_EXECUTABLE)
  27. SET(PATCH_COMMAND git apply --whitespace=fix --inaccurate-eof)
  28. # Find patch files
  29. FILE(GLOB_RECURSE PATCH_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
  30. ${CMAKE_CURRENT_SOURCE_DIR}/patches/*.patch
  31. ${CMAKE_CURRENT_SOURCE_DIR}/patches/*.diff)
  32. # Execute patch files
  33. FOREACH(file ${PATCH_FILES})
  34. MESSAGE(STATUS "Found patch file ${file}.")
  35. EXECUTE_PROCESS(COMMAND ${PATCH_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${WORKING_DIR})
  36. ENDFOREACH(file)
  37. ENDIF(PATCH_EXECUTABLE)
  38. ENDIF(APPLY_COVERITY_PATCH)
  39. ## Add include/ to include directories
  40. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/ ${CMAKE_CURRENT_BINARY_DIR})
  41. ## Fix Windows exports
  42. INCLUDE (GenerateExportHeader)
  43. ## build list of source files
  44. FILE(GLOB SQUIRREL_SOURCES squirrel/*.cpp sqstdlib/*.cpp sqstdlib/*.c)
  45. FILE(GLOB SQUIRREL_HEADERS include/*.h)
  46. ## Add in squirrel debug stuff
  47. OPTION(ENABLE_SQDBG "Build squirrel script interpreter with debugging options" OFF)
  48. IF(ENABLE_SQDBG)
  49. INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}/squirrel/)
  50. FILE(GLOB SQDBG_SOURCES sqdbg/*.cpp)
  51. SET(SQUIRREL_SOURCES ${SQDBG_SOURCES} ${SQUIRREL_SOURCES})
  52. ENDIF(ENABLE_SQDBG)
  53. # the squirrel sources are out of our control so don't be too pedantic about
  54. # them
  55. SET(CMAKE_CXX_FLAGS "")
  56. SET(CMAKE_C_FLAGS "")
  57. ## define a target for building the library
  58. LIST(SORT SQUIRREL_SOURCES)
  59. ADD_LIBRARY(squirrel ${SQUIRREL_SOURCES})
  60. GENERATE_EXPORT_HEADER( squirrel
  61. BASE_NAME squirrel
  62. EXPORT_MACRO_NAME SQUIRREL_API
  63. EXPORT_FILE_NAME squirrel_Export.h
  64. STATIC_DEFINE squirrel_BUILT_AS_STATIC
  65. )
  66. # use standardized variable name
  67. set(LIB_SUBDIR "lib${LIB_SUFFIX}"
  68. CACHE STRING "Subdirectory of prefix into which libraries are installed (e.g., lib32, lib64)")
  69. IF(SQUIRREL_IS_SUBPROJECT)
  70. IF(BUILD_SHARED_LIBS)
  71. INSTALL(TARGETS squirrel
  72. RUNTIME DESTINATION bin
  73. LIBRARY DESTINATION ${LIB_SUBDIR})
  74. ENDIF()
  75. ELSE()
  76. INSTALL(TARGETS squirrel
  77. RUNTIME DESTINATION bin
  78. ARCHIVE DESTINATION ${LIB_SUBDIR}
  79. LIBRARY DESTINATION ${LIB_SUBDIR}
  80. COMPONENT squirrel)
  81. INSTALL(FILES ${SQUIRREL_HEADERS} ${CMAKE_BINARY_DIR}/squirrel_Export.h
  82. DESTINATION include)
  83. ENDIF()