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 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. cmake_minimum_required(VERSION 3.0)
  2. project(swan)
  3. find_package(SFML 2.5 COMPONENTS graphics system window REQUIRED)
  4. find_package(ImGui-SFML REQUIRED)
  5. set(CMAKE_CXX_CLANG_TIDY
  6. clang-tidy
  7. --header-filter=.*
  8. --checks=-*,bugprone-*,cert-*,performance-*,clang-analyzer-*,-cert-dcl16-c,-cert-err58-cpp,-clang-analyzer-optin.cplusplus.VirtualCall)
  9. add_compile_options(-std=c++2a -Wall -Wextra -Wpedantic -Wno-unused-parameter)
  10. if(CMAKE_BUILD_TYPE STREQUAL Sanitize OR CMAKE_BUILD_TYPE STREQUAL "")
  11. message(STATUS "Build mode: Sanitize")
  12. add_compile_options(-g -fsanitize=address)
  13. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
  14. elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
  15. message(STATUS "Build mode: Debug")
  16. add_compile_options(-g)
  17. elseif(CMAKE_BUILD_TYPE STREQUAL Release)
  18. message(STATUS "Build mode: Release")
  19. add_compile_options(-O3 -flto)
  20. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
  21. else()
  22. message(FATAL_ERROR "CMAKE_BUILD_TYPE must be Debug or Release.")
  23. endif()
  24. add_subdirectory(third_party)
  25. set(libraries sfml-graphics sfml-system sfml-window sfml-audio ImGui-SFML::ImGui-SFML imgui dl)
  26. # We want to be able to use C++20 designated initializers,
  27. # but Clang doesn't support them yet.
  28. # Remove once Clang 9.1 or something comes out.
  29. add_compile_options(-Wno-c99-extensions)
  30. include_directories(
  31. ${PROJECT_SOURCE_DIR}/libswan/include
  32. ${PROJECT_SOURCE_DIR}/third_party)
  33. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/swan/libswan;${CMAKE_INSTALL_PREFIX}/swan/third_party")
  34. add_subdirectory(libswan)
  35. add_subdirectory(core.mod)
  36. add_executable(swan
  37. src/main.cc)
  38. target_link_libraries(swan libswan ${libraries} imgui)
  39. set(assets
  40. assets/icon.png
  41. assets/music/happy-1.wav)
  42. foreach(a ${assets})
  43. configure_file("${a}" "${a}" COPYONLY)
  44. endforeach(a)
  45. install(TARGETS swan DESTINATION swan)
  46. install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/assets DESTINATION swan)