summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorjussi2022-02-22 02:49:15 +0200
committerjussi2022-02-22 02:49:15 +0200
commit8800de59fa704cfe60ac980db079b44042639684 (patch)
treeaaa2b54327b78a564bc05829a1c66c6e4f3b53de /CMakeLists.txt
parent612ede6da40550fc0b14c1370f616fc6e83df550 (diff)
downloadreilua-enhanced-8800de59fa704cfe60ac980db079b44042639684.tar.gz
reilua-enhanced-8800de59fa704cfe60ac980db079b44042639684.tar.bz2
reilua-enhanced-8800de59fa704cfe60ac980db079b44042639684.zip
Web build.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt78
1 files changed, 42 insertions, 36 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c0645bf..be2d7f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,51 +1,57 @@
cmake_minimum_required( VERSION 3.9 )
project( ReiLua )
+# To make web build
+# cmake .. -DCMAKE_TOOLCHAIN_FILE=<YOUR PATH HERE>/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DPLATFORM=Web
+
set( CMAKE_C_STANDARD 99 ) # Requires C99 standard
-if( UNIX )
- set( CMAKE_C_COMPILER "gcc" )
-elseif( APPLE )
- set( CMAKE_C_COMPILER "clang" )
-# elseif( WIN32 )
-# set( CMAKE_C_COMPILER "mingw32" )
+if( DEBUG )
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb -std=c99 -Wall -pedantic -fno-common" )
+else()
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c99 -Wall -pedantic -fno-common" )
endif()
-# set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb -std=c99 -Wall -pedantic -fno-common" )
-set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c99 -Wall -pedantic -fno-common" )
-
include_directories( include )
file( GLOB SOURCES "src/*.c" )
add_executable( ${PROJECT_NAME} ${SOURCES} )
-if( SHARED )
- message( Shared )
- find_package( raylib 4.0 REQUIRED ) # Requires at least version 4.0
- target_link_libraries( ${PROJECT_NAME} raylib )
- target_link_libraries( ${PROJECT_NAME} lua )
-else()
- message( Static )
- target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/libraylib.a )
- target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/liblua.a )
- # target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/libluajit.a )
-endif()
-
-if( UNIX )
- if( DRM ) # Mainly for Raspberry pi
- # target_link_libraries( ${PROJECT_NAME} GLESv2 EGL drm gbm rt bcm_host m dl pthread )
- target_link_libraries( ${PROJECT_NAME} GLESv2 EGL drm gbm rt m dl pthread )
+if( EMSCRIPTEN ) # Web
+ target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/web/libraylib.a )
+ target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/web/liblua.a )
+
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY" )
+ set( CMAKE_EXECUTABLE_SUFFIX ".html" ) # This line is used to set your executable to build with the emscripten html template so taht you can directly open it.
+ set( resources_dir "resources" )
+ set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}" )
+else() # Desktop
+ if( SHARED )
+ message( Shared )
+ find_package( raylib 4.0 REQUIRED ) # Requires at least version 4.0
+ target_link_libraries( ${PROJECT_NAME} raylib )
+ target_link_libraries( ${PROJECT_NAME} lua )
else()
- target_link_libraries( ${PROJECT_NAME} m dl pthread )
+ message( Static )
+ target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/libraylib.a )
+ target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/liblua.a )
endif()
-endif()
-if( WIN32 )
- target_link_libraries( ${PROJECT_NAME} mingw32 opengl32 gdi32 winmm )
-endif()
-
-# Checks if OSX and links appropriate frameworks (Only required on MacOS)
-if( APPLE )
- target_link_libraries( ${PROJECT_NAME} "-framework IOKit" )
- target_link_libraries( ${PROJECT_NAME} "-framework Cocoa" )
- target_link_libraries( ${PROJECT_NAME} "-framework OpenGL" )
+ if( UNIX )
+ set( CMAKE_C_COMPILER "gcc" )
+
+ if( DRM ) # Mainly for Raspberry pi
+ # target_link_libraries( ${PROJECT_NAME} GLESv2 EGL drm gbm rt bcm_host m dl pthread )
+ target_link_libraries( ${PROJECT_NAME} GLESv2 EGL drm gbm rt m dl pthread )
+ else()
+ target_link_libraries( ${PROJECT_NAME} m dl pthread )
+ endif()
+ elseif( APPLE )
+ set( CMAKE_C_COMPILER "clang" )
+
+ target_link_libraries( ${PROJECT_NAME} "-framework IOKit" )
+ target_link_libraries( ${PROJECT_NAME} "-framework Cocoa" )
+ target_link_libraries( ${PROJECT_NAME} "-framework OpenGL" )
+ elseif( WIN32 )
+ target_link_libraries( ${PROJECT_NAME} mingw32 opengl32 gdi32 winmm )
+ endif()
endif()