summaryrefslogtreecommitdiffhomepage
path: root/examples/CMakeLists.txt
diff options
context:
space:
mode:
authorhristo <[email protected]>2020-12-13 21:29:47 +0200
committerGitHub <[email protected]>2020-12-13 20:29:47 +0100
commit6e79476650321cd08c6814a304887d378b54799f (patch)
treef4a6661b55a02cbf45db88713bf22b879198894b /examples/CMakeLists.txt
parent11ebb54674bd78bc02ce3cf4e0e2eab96fe22f88 (diff)
downloadraylib-6e79476650321cd08c6814a304887d378b54799f.tar.gz
raylib-6e79476650321cd08c6814a304887d378b54799f.zip
Fixed the build for web using CMake. (#1452)
* Fixed the build for web using CMake. I found that the build for me was failing and I added some if defined checks in the core.c file where the glfwSetWindowAttrib was used. (error: implicit declaration of function 'glfwSetWindowAttrib' is invalid in C99 [-Werror,-Wimplicit-function-declaration]) I also changed some values in the toolchain file so that it correctly uses the .bat files when on windows. * Cleaned up the additional variables (they are not important) * Added more improvements to cmakelists Added the option to use the system provided Emscripten toolchain to be more uniform with other libraries. Fixed and issue which prevented example being built from cmake and also building with html extensions properly. * Fixed ENUM to STRING because of a missed warning
Diffstat (limited to 'examples/CMakeLists.txt')
-rw-r--r--examples/CMakeLists.txt9
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 08b97ea9..57ba74d4 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -28,7 +28,6 @@ if (APPLE AND NOT CMAKE_SYSTEM STRLESS "Darwin-18.0.0")
add_definitions(-DGL_SILENCE_DEPRECATION)
MESSAGE(AUTHOR_WARNING "OpenGL is deprecated starting with macOS 10.14 (Mojave)!")
endif()
-set(OUTPUT_EXT)
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
include(CheckIncludeFile)
@@ -85,12 +84,12 @@ elseif(${PLATFORM} MATCHES "Web")
# Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
- set(OUTPUT_EXT ".html")
+ set(CMAKE_EXECUTABLE_SUFFIX ".html")
# Remove the -rdynamic flag because otherwise emscripten
# does not generate HTML+JS+WASM files, only a non-working
# and fat HTML
- string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
+ string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}")
endif()
include_directories(BEFORE SYSTEM others/external/include)
@@ -103,7 +102,7 @@ endif()
foreach(example_source ${example_sources})
# Create the basename for the example
get_filename_component(example_name ${example_source} NAME)
- string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
+ string(REPLACE ".c" "" example_name ${example_name})
# Setup the example
add_executable(${example_name} ${example_source})
@@ -125,7 +124,7 @@ if (${PLATFORM} MATCHES "Desktop")
foreach (example_source "others/rlgl_standalone.c")
# Create the basename for the example
get_filename_component(example_name ${example_source} NAME)
- string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
+ string(REPLACE ".c" "" example_name ${example_name})
add_executable(${example_name} ${example_source})
add_dependencies(${example_name} raylib)
target_link_libraries(${example_name} ${raylib_LDFLAGS})