Hook up examples to CMake

This commit is contained in:
sfan5 2021-04-22 09:43:53 +02:00
parent 3152a6cc46
commit 5411ec4f03
5 changed files with 61 additions and 14 deletions

2
.gitignore vendored

@ -4,3 +4,5 @@ cmake_install.cmake
Makefile
*.so*
*.a
*.exe
bin/Linux

@ -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}

@ -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:

45
examples/CMakeLists.txt Normal file

@ -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()

@ -1,8 +0,0 @@
DIRS = $(wildcard [0123]* Demo)
all: $(DIRS)
$(DIRS):
-@cd $@ && make clean && make
.PHONY: $(DIRS)