A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. cmake_minimum_required(VERSION 3.0)
  2. project(swan)
  3. find_package(SDL2 REQUIRED)
  4. option(USE_CLANG_TIDY "Use clang-tidy for additional checks" ON)
  5. if(USE_CLANG_TIDY)
  6. set(CMAKE_CXX_CLANG_TIDY
  7. clang-tidy
  8. "--header-filter=(libswan|core.mod|src)/.*"
  9. --checks=-*,bugprone-*,cert-*,performance-*,clang-analyzer-*,-cert-dcl16-c,-cert-err58-cpp,-clang-analyzer-optin.cplusplus.VirtualCall)
  10. endif()
  11. if(CMAKE_EXPORT_COMPILE_COMMANDS)
  12. add_custom_target(compile_commands ALL
  13. BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
  14. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  15. COMMAND
  16. compdb -p ${CMAKE_CURRENT_BINARY_DIR} list
  17. > ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json)
  18. endif()
  19. add_compile_options(-std=c++2a -Wall -Wextra -Wpedantic -Wno-unused-parameter)
  20. if(CMAKE_BUILD_TYPE STREQUAL Sanitize OR CMAKE_BUILD_TYPE STREQUAL "")
  21. message(STATUS "Build mode: Sanitize")
  22. add_compile_options(-g -Og -fsanitize=address -fsanitize=undefined)
  23. add_link_options(-fsanitize=address -fsanitize=undefined)
  24. elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
  25. message(STATUS "Build mode: Debug")
  26. add_compile_options(-g -O0)
  27. elseif(CMAKE_BUILD_TYPE STREQUAL Profile)
  28. message(STATUS "Build mode: Profile")
  29. add_compile_options(-g -Og -pg)
  30. add_link_options(-pg)
  31. elseif(CMAKE_BUILD_TYPE STREQUAL Release)
  32. message(STATUS "Build mode: Release")
  33. add_compile_options(-O3 -flto)
  34. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
  35. else()
  36. message(FATAL_ERROR "CMAKE_BUILD_TYPE must be Debug or Release.")
  37. endif()
  38. add_subdirectory(third_party)
  39. set(libraries imgui SDL2 SDL2_image dl z)
  40. # We want to be able to use C++20 designated initializers,
  41. # but Clang doesn't support them yet.
  42. # Remove once Clang 9.1 or something comes out.
  43. add_compile_options(-Wno-c99-extensions)
  44. include_directories(
  45. ${PROJECT_SOURCE_DIR}/third_party
  46. ${SDL2_INCLUDE_DIRS})
  47. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib64;${CMAKE_INSTALL_PREFIX}/swan/libswan;${CMAKE_INSTALL_PREFIX}/swan/third_party")
  48. add_subdirectory(libswan)
  49. add_subdirectory(core.mod)
  50. add_executable(swan
  51. src/main.cc)
  52. target_link_libraries(swan libswan ${libraries})
  53. set(assets
  54. assets/icon.png
  55. assets/music/happy-1.wav)
  56. foreach(a ${assets})
  57. configure_file("${a}" "${a}" COPYONLY)
  58. endforeach(a)
  59. install(TARGETS swan DESTINATION swan)
  60. install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/assets DESTINATION swan)
  61. add_custom_target(check DEPENDS check_libswan)