1- cmake_minimum_required (VERSION 3.11 )
1+ cmake_minimum_required (VERSION 3.24 )
22
3- set (CMAKE_CXX_STANDARD 14 )
3+ set (CMAKE_CXX_STANDARD 17 )
44set (CMAKE_CXX_STANDARD_REQUIRED ON )
55set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR } /build)
6+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
67
7- project (Mazes)
8+ include (FetchContent )
9+
10+ project (Mazes)
811
912# Source code
1013file (GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR } /src/*.cpp )
14+ file (GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR } /src/*.hpp )
1115file (GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR } /src/*.h )
1216
13- add_executable (${PROJECT_NAME } ${SOURCES} ${HEADERS} )
17+ add_executable (${PROJECT_NAME } ${SOURCES} ${HEADERS} )
1418
1519target_compile_options (${PROJECT_NAME } PRIVATE -Wall -Wextra -pedantic )
1620
17- # Find libs
18- find_library (ALLEGRO_LIBRARY NAMES alleg44 alleg REQUIRED )
19- find_library (ALLEGRO_PNG_LIBRARY NAMES loadpng REQUIRED )
20- find_library (ALLEGRO_OGG_LIBRARY NAMES logg REQUIRED )
21-
21+ FetchContent_Declare (
22+ asw
23+ GIT_REPOSITORY https://github.com/adsgames/asw.git
24+ GIT_TAG v0.5.4
25+ )
26+ FetchContent_MakeAvailable (asw)
2227
2328# Link Libs
24- target_link_libraries (${PROJECT_NAME } ${ALLEGRO_LIBRARY} )
25- target_link_libraries (${PROJECT_NAME } ${ALLEGRO_PNG_LIBRARY} )
26- target_link_libraries (${PROJECT_NAME } ${ALLEGRO_OGG_LIBRARY} )
27-
29+ if (MINGW)
30+ target_link_libraries (${PROJECT_NAME } -lmingw32 )
31+ endif (MINGW )
32+
33+ target_link_libraries (
34+ ${PROJECT_NAME }
35+ asw
36+ )
37+
38+ # Emscripten support
39+ if (EMSCRIPTEN)
40+ set_target_properties (${PROJECT_NAME } PROPERTIES OUTPUT_NAME "index" )
41+ set (CMAKE_EXECUTABLE_SUFFIX ".html" )
42+
43+ target_link_libraries (
44+ ${PROJECT_NAME }
45+ -sWASM=1
46+ -sALLOW_MEMORY_GROWTH=1
47+ -sMAXIMUM_MEMORY=1gb
48+ )
49+
50+ set_target_properties (
51+ ${PROJECT_NAME }
52+ PROPERTIES
53+ LINK_FLAGS
54+ "--preload-file ${CMAKE_CURRENT_LIST_DIR } /assets@/assets --use-preload-plugins --shell-file ${CMAKE_CURRENT_LIST_DIR } /index.html"
55+ )
56+ endif (EMSCRIPTEN )
57+
58+ file (COPY ${CMAKE_CURRENT_LIST_DIR } /assets DESTINATION ${CMAKE_BINARY_DIR } /build )
0 commit comments