generated from It-Club/RaylibTemplate-C
Initial commit
This commit is contained in:
51
CMakeLists.txt
Normal file
51
CMakeLists.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
|
||||
project(game C CXX)
|
||||
|
||||
# Generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Dependencies
|
||||
find_package(raylib QUIET) # QUIET or REQUIRED
|
||||
if(NOT raylib_FOUND) # If there's none, fetch and build raylib
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
raylib
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP OFF
|
||||
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
||||
GIT_TAG master
|
||||
)
|
||||
FetchContent_GetProperties(raylib)
|
||||
if(NOT raylib_POPULATED) # Have we downloaded raylib yet?
|
||||
set(FETCHCONTENT_QUIET NO)
|
||||
FetchContent_MakeAvailable(raylib)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Our Project
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
# Add source files
|
||||
file(GLOB_RECURSE PROJECTSOURCES "src/*.c" "src/*.cpp")
|
||||
target_sources(${PROJECT_NAME} PRIVATE ${PROJECTSOURCES})
|
||||
|
||||
# Include directories
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
"data"
|
||||
${raylib_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(${PROJECT_NAME} raylib)
|
||||
|
||||
# Web Configurations
|
||||
if(${PLATFORM} STREQUAL "Web")
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s GL_ENABLE_GET_PROC_ADDRESS=1 -s SINGLE_FILE=1 --shell-file ${CMAKE_SOURCE_DIR}/src/minshell.html")
|
||||
endif()
|
||||
|
||||
# macOS frameworks
|
||||
if(APPLE)
|
||||
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
|
||||
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
|
||||
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
|
||||
endif()
|
||||
Reference in New Issue
Block a user