A 2D tile-based sandbox game.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CMakeLists.txt 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. add_compile_options(-std=c++2a -Wall -Wextra -Wpedantic -Wno-unused-parameter)
  12. if(CMAKE_BUILD_TYPE STREQUAL Sanitize OR CMAKE_BUILD_TYPE STREQUAL "")
  13. message(STATUS "Build mode: Sanitize")
  14. add_compile_options(-g -Og -fsanitize=address -fsanitize=undefined)
  15. add_link_options(-fsanitize=address -fsanitize=undefined)
  16. elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
  17. message(STATUS "Build mode: Debug")
  18. add_compile_options(-g -O0)
  19. elseif(CMAKE_BUILD_TYPE STREQUAL Profile)
  20. message(STATUS "Build mode: Profile")
  21. add_compile_options(-g -Og -pg)
  22. add_link_options(-pg)
  23. elseif(CMAKE_BUILD_TYPE STREQUAL Release)
  24. message(STATUS "Build mode: Release")
  25. add_compile_options(-O3 -flto)
  26. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
  27. else()
  28. message(FATAL_ERROR "CMAKE_BUILD_TYPE must be Debug or Release.")
  29. endif()
  30. add_subdirectory(third_party)
  31. set(libraries imgui SDL2 SDL2_image dl z)
  32. # We want to be able to use C++20 designated initializers,
  33. # but Clang doesn't support them yet.
  34. # Remove once Clang 9.1 or something comes out.
  35. add_compile_options(-Wno-c99-extensions)
  36. include_directories(
  37. ${PROJECT_SOURCE_DIR}/third_party
  38. ${SDL2_INCLUDE_DIRS})
  39. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib64;${CMAKE_INSTALL_PREFIX}/swan/libswan;${CMAKE_INSTALL_PREFIX}/swan/third_party")
  40. add_subdirectory(libswan)
  41. add_subdirectory(core.mod)
  42. add_executable(swan
  43. src/main.cc)
  44. target_link_libraries(swan libswan ${libraries})
  45. set(assets
  46. assets/icon.png
  47. assets/music/happy-1.wav)
  48. foreach(a ${assets})
  49. configure_file("${a}" "${a}" COPYONLY)
  50. endforeach(a)
  51. install(TARGETS swan DESTINATION swan)
  52. install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/assets DESTINATION swan)
  53. add_custom_target(check DEPENDS check_libswan)