CMakeLists.txt 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. cmake_minimum_required(VERSION 2.8)
  2. # Set policy: link_directories is relative to source dir
  3. cmake_policy(SET CMP0015 NEW)
  4. # Set the project name.
  5. project(ERUTA C)
  6. # Play with PCC
  7. # SET(CMAKE_C_COMPILER /usr/local/bin/pcc)
  8. # Play with UCC
  9. # SET(CMAKE_C_COMPILER /usr/local/lib/ucc/ucc)
  10. # tell CMake to search first in the cmake subdirectory for FIND_PACKAGE() or INCLUDE()
  11. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/)
  12. include(CheckCSourceCompiles)
  13. include(CheckCXXSourceCompiles)
  14. if(CMAKE_COMPILER_IS_GNUCC)
  15. set(COMPILER_GCC 1)
  16. set(CMAKE_C_FLAGS "-W -Wall -Wno-unused -Wno-unknown-pragmas -g3 -gdwarf-2 -std=c99 -ffast-math -fsanitize=address -fno-omit-frame-pointer -fstrict-aliasing -Wstrict-aliasing=2")
  17. # set(CMAKE_LD_FLAGS "-pg")
  18. # always use gnu99, debugging, all warnings except unused and unknown pragmas.
  19. # when compiling with gnu compiler.
  20. # Warn about alisasing because otherwise aliasing problems it may not be detected.
  21. else(CMAKE_COMPILER_IS_GNUCC)
  22. set(CMAKE_C_FLAGS "-W -Wall -Wno-unused -Wno-unknown-pragmas -g -std=c99 -ffast-math -fstrict-aliasing -Wstrict-aliasing=2")
  23. endif(CMAKE_COMPILER_IS_GNUCC)
  24. # or for PCC
  25. # set(CMAKE_C_FLAGS "-fpic -fPIC")
  26. find_package(Mruby REQUIRED)
  27. # Finds Allegro using pkgconfig, so it must be configured correctly
  28. find_package(Allegro5 REQUIRED)
  29. find_package(PNG REQUIRED)
  30. find_package(JPEG REQUIRED)
  31. # Set include and lib dirs.
  32. include_directories(${ALLEGRO_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${JPEG_INCLUDE_DIR} ${MRUBY_INCLUDE_DIR})
  33. set(ERUTA_LIBS ${LIBS} ${OBJC_LIBRARIES} ${ALLEGRO_LIBRARIES} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${MRUBY_LIBRARIES})
  34. include_directories("include")
  35. include_directories("include/zori")
  36. include_directories("include/tr")
  37. include_directories("include/proto")
  38. include_directories("include/zori/proto")
  39. include_directories("include/tr/proto")
  40. # add_subdirectory("src")
  41. include(ErutaFiles)
  42. set_source_files_properties(${ERUTA_SRC_FILES} PROPERTIES LANGUAGE C)
  43. # set_source_files_properties(${ERUTA_OBJC_SRC_FILES} PROPERTIES LANGUAGE C)
  44. # src/BNObject.m
  45. # set_source_files_properties(BNObject.m PROPERTIES LANGUAGE C)
  46. # eruta exe in the bin subdir (first one should work, but doesnt, hmmm...)
  47. set(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  48. set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
  49. add_library(ERUTA_OBJECTS OBJECT ${ERUTA_SRC_FILES})
  50. add_executable(eruta $<TARGET_OBJECTS:ERUTA_OBJECTS> src/main.c)
  51. target_link_libraries(eruta ${ERUTA_LIBS})
  52. enable_testing()
  53. # Let ctest run valgrind
  54. # test exe in the test subdir (first one should work, but doesnt, hmmm...)
  55. set(CMAKE_CTEST_OPTIONS --output-on-failure)
  56. set(CTEST_OUTPUT_ON_FAILURE TRUE)
  57. set(CTEST_MEMORYCHECK_COMMAND:FILEPATH "/usr/bin/valgrind")
  58. add_subdirectory("test")