]> git.lizzy.rs Git - irrlicht.git/commitdiff
Hook up examples to CMake
authorsfan5 <sfan5@live.de>
Thu, 22 Apr 2021 07:43:53 +0000 (09:43 +0200)
committersfan5 <sfan5@live.de>
Thu, 22 Apr 2021 07:43:53 +0000 (09:43 +0200)
.gitignore
CMakeLists.txt
README.md
examples/CMakeLists.txt [new file with mode: 0644]
examples/Makefile [deleted file]

index 07a07d57195fd87549a35fa06921edd2ce59de27..43b29fc5e3f7dfc064a239b680f8c5ff20b7e124 100644 (file)
@@ -4,3 +4,5 @@ cmake_install.cmake
 Makefile
 *.so*
 *.a
+*.exe
+bin/Linux
index 5adbb4f7a9961bcef0218cc9bab0bc1e2b78ed0f..58e706e79e260cb989eef31946c22d643be311ff 100644 (file)
@@ -8,17 +8,19 @@ project(Irrlicht
 message(STATUS "*** Building IrrlichtMt ${PROJECT_VERSION} ***")
 
 if(ANDROID)
-       set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/Android)
+       set(sysname Android)
 elseif(APPLE)
-       set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/OSX)
+       set(sysname OSX)
+elseif(MSVC)
+       set(sysname Win32-VisualStudio)
 elseif(WIN32)
-       # good enough
-       set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/Win32-gcc)
+       set(sysname Win32-gcc)
 else()
-       set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/Linux)
+       set(sysname Linux)
 endif()
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${sysname})
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${sysname})
 
 if(NOT CMAKE_BUILD_TYPE)
        set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
@@ -27,6 +29,11 @@ endif()
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 add_subdirectory(source/Irrlicht)
 
+option(BUILD_EXAMPLES "Build example applications" FALSE)
+if(BUILD_EXAMPLES)
+       add_subdirectory(examples)
+endif()
+
 # Installation of library and headers.
 include(GNUInstallDirs)
 install(TARGETS ${INSTALL_TARGETS}
index aedc07358a97193d03900edccc8b5b64a040b78c..243cdea97ef0e72fe234677c077c87f954ece62f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ The following libraries are required to be installed:
 
 Aside from standard search options (`ZLIB_INCLUDE_DIR`, `ZLIB_LIBRARY`, ...) the following options are available:
 * `BUILD_SHARED_LIBS` (default: `ON`) - Build IrrlichtMt as a shared library
+* `BUILD_EXAMPLES` (default: `OFF`) - Build example applications
 
 e.g. on a Linux system you might want to build for local use like this:
 
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e35f38c
--- /dev/null
@@ -0,0 +1,45 @@
+
+set(IRREXAMPLES
+       01.HelloWorld
+       02.Quake3Map
+       03.CustomSceneNode
+       04.Movement
+       05.UserInterface
+       06.2DGraphics
+       07.Collision
+       08.SpecialFX
+       09.Meshviewer
+       10.Shaders
+       11.PerPixelLighting
+       12.TerrainRendering
+       13.RenderToTexture
+       15.LoadIrrFile
+       16.Quake3MapShader
+       18.SplitScreen
+       19.MouseAndJoystick
+       20.ManagedLights
+       21.Quake3Explorer
+       22.MaterialViewer
+       23.SMeshHandling
+       24.CursorControl
+       25.XmlHandling
+       26.OcclusionQuery
+       27.PostProcessing
+       28.CubeMapping
+       30.Profiling
+)
+
+if(WIN32)
+       list(APPEND IRREXAMPLES 14.Win32Window)
+endif()
+
+foreach(exname IN ITEMS ${IRREXAMPLES})
+       file(GLOB sources "${CMAKE_CURRENT_SOURCE_DIR}/${exname}/*.cpp")
+       add_executable(${exname} ${sources})
+
+       target_include_directories(${exname} PRIVATE
+               ${CMAKE_SOURCE_DIR}/include
+               ${CMAKE_CURRENT_SOURCE_DIR}/${exname}
+       )
+       target_link_libraries(${exname} IrrlichtMt)
+endforeach()
diff --git a/examples/Makefile b/examples/Makefile
deleted file mode 100644 (file)
index e187a00..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-DIRS = $(wildcard [0123]* Demo)
-
-all: $(DIRS)
-
-$(DIRS):
-       -@cd $@ && make clean && make
-
-.PHONY: $(DIRS)