CMakeLists.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. cmake_minimum_required(VERSION 3.14)
  2. include(FetchContent)
  3. # Set the project name. This is not the executable program's name!
  4. project(graphical_template)
  5. if(NOT EMSCRIPTEN)
  6. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined,address")
  7. endif()
  8. FetchContent_Declare(
  9. raylib
  10. URL https://github.com/manuel5975p/raylib/archive/refs/tags/5.1.1.tar.gz
  11. DOWNLOAD_EXTRACT_TIMESTAMP True #This option is not required but suppresses a warning
  12. )
  13. FetchContent_MakeAvailable(raylib)
  14. add_executable(index "hexagon.cpp")
  15. # Link raylib to main
  16. target_include_directories(index PUBLIC "${raylib_SOURCE_DIR}/src")
  17. FetchContent_Declare(
  18. eigen3
  19. URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
  20. )
  21. FetchContent_MakeAvailable(eigen3)
  22. file(
  23. DOWNLOAD
  24. https://raw.githubusercontent.com/raysan5/raygui/4.0/src/raygui.h
  25. "${CMAKE_BINARY_DIR}/downloaded_headers/raygui_dl.h"
  26. )
  27. include_directories(${CMAKE_BINARY_DIR}/downloaded_headers/)
  28. target_link_libraries(index PUBLIC raylib Eigen3::Eigen)
  29. target_compile_features(index PUBLIC cxx_std_20)
  30. if (EMSCRIPTEN)
  31. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lidbfs.js -s USE_GLFW=3 --shell-file ${CMAKE_CURRENT_LIST_DIR}/web/minshell.html -s GL_ENABLE_GET_PROC_ADDRESS=1")
  32. set(CMAKE_EXECUTABLE_SUFFIX ".html") # This line is used to set your executable to build with the emscripten html template so that you can directly open it.
  33. endif ()