summaryrefslogtreecommitdiffhomepage
path: root/projects/CMake/CMakeLists.txt
diff options
context:
space:
mode:
authorAhmad Fatoum <[email protected]>2018-07-29 18:23:23 +0200
committerAhmad Fatoum <[email protected]>2018-07-29 18:27:59 +0200
commite82505b873370b8f3a914a079062c21e64353210 (patch)
tree92e16ff3e7dfb4b4e7696fa58cb67781a0fea5ff /projects/CMake/CMakeLists.txt
parent548dbeb1ca1e62a4893bb7041228915a97cd5b0e (diff)
downloadraylib-e82505b873370b8f3a914a079062c21e64353210.tar.gz
raylib-e82505b873370b8f3a914a079062c21e64353210.zip
Add projects/CMake example
The CMakeLists.txt checks for an installed raylib and downloads and installs one if none is found. Afterwards, it builds core_basic_window.c
Diffstat (limited to 'projects/CMake/CMakeLists.txt')
-rw-r--r--projects/CMake/CMakeLists.txt37
1 files changed, 37 insertions, 0 deletions
diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt
new file mode 100644
index 00000000..68c976e5
--- /dev/null
+++ b/projects/CMake/CMakeLists.txt
@@ -0,0 +1,37 @@
+cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
+project(example)
+
+find_package(raylib 2.0 QUIET) # Let CMake search for a raylib-config.cmake
+
+# You could change the QUIET above to REQUIRED and remove this if() clause
+# This part downloads raylib and builds it if it's not installed on your system
+if (NOT raylib_FOUND) # If there's none, fetch and build raylib
+ include(FetchContent)
+
+ FetchContent_Declare(
+ raylib
+ URL https://github.com/raysan5/raylib/archive/master.tar.gz
+ )
+
+ FetchContent_GetProperties(raylib)
+ if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
+ set(FETCHCONTENT_QUIET NO)
+ FetchContent_Populate(raylib)
+
+ set(BUILD_EXAMPLES OFF) # don't build the supplied examples
+ set(BUILD_GAMES OFF) # or games
+
+ # build raylib
+ add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
+
+ endif()
+
+endif()
+
+# This is the main part:
+
+add_executable(${PROJECT_NAME} core_basic_window.c)
+#set(raylib_VERBOSE 1)
+target_link_libraries(${PROJECT_NAME} raylib)
+
+# That's it! You should have an example executable that you can run. Have fun!