Skip to content

Commit

Permalink
Added CMake variables to select the modules to be built
Browse files Browse the repository at this point in the history
This addresses issue #798.
  • Loading branch information
MarioLiebisch committed Nov 5, 2016
1 parent 67ef694 commit 40cb8cd
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 31 deletions.
38 changes: 26 additions & 12 deletions CMakeLists.txt
Expand Up @@ -68,11 +68,21 @@ else()
set(SFML_BUILD_EXAMPLES FALSE)
endif()

# add options to select which modules to build
sfml_set_option(SFML_BUILD_WINDOW TRUE BOOL "TRUE to build SFML's Window module. This setting is ignored, if the graphics module is built.")
sfml_set_option(SFML_BUILD_GRAPHICS TRUE BOOL "TRUE to build SFML's Graphics module.")
if(NOT SFML_OS_IOS)
sfml_set_option(SFML_BUILD_AUDIO TRUE BOOL "TRUE to build SFML's Audio module.")
endif()
sfml_set_option(SFML_BUILD_NETWORK TRUE BOOL "TRUE to build SFML's Network module.")

# add an option for building the API documentation
sfml_set_option(SFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it")

# add an option for choosing the OpenGL implementation
sfml_set_option(SFML_OPENGL_ES ${OPENGL_ES} BOOL "TRUE to use an OpenGL ES implementation, FALSE to use a desktop OpenGL implementation")
if(SFML_BUILD_GRAPHICS OR SFML_BUILD_WINDOW)
sfml_set_option(SFML_OPENGL_ES ${OPENGL_ES} BOOL "TRUE to use an OpenGL ES implementation, FALSE to use a desktop OpenGL implementation")
endif()

# Mac OS X specific options
if(SFML_OS_MACOSX)
Expand Down Expand Up @@ -193,11 +203,11 @@ if(SFML_OS_MACOSX)
endif()

# only the default architecture (i.e. 64-bit) is supported
if(CMAKE_OSX_ARCHITECTURES AND NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
if(CMAKE_OSX_ARCHITECTURES AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
message(FATAL_ERROR "Only 64-bit architecture is supported")
return()
endif()

# configure Xcode templates
set(XCODE_TEMPLATES_ARCH "\$(NATIVE_ARCH_ACTUAL)")
endif()
Expand Down Expand Up @@ -329,31 +339,33 @@ if(SFML_OS_WINDOWS)
elseif(SFML_OS_MACOSX)

# install extlibs dependencies only when used
if("${FLAC_LIBRARY}" STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/FLAC.framework")
if(SFML_BUILD_AUDIO AND FLAC_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/FLAC.framework")
install(DIRECTORY extlibs/libs-osx/Frameworks/FLAC.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
endif()

if("${FREETYPE_LIBRARY}" STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/freetype.framework")
install(DIRECTORY extlibs/libs-osx/Frameworks/freetype.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
if(SFML_BUILD_GRAPHICS)
if(FREETYPE_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/freetype.framework")
install(DIRECTORY extlibs/libs-osx/Frameworks/freetype.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
endif()
endif()

if("${OGG_LIBRARY}" STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/ogg.framework")
if(OGG_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/ogg.framework")
install(DIRECTORY extlibs/libs-osx/Frameworks/ogg.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
endif()

if("${VORBIS_LIBRARY}" STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbis.framework")
if(VORBIS_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbis.framework")
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbis.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
endif()

if("${VORBISENC_LIBRARY}" STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbisenc.framework")
if(VORBISENC_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbisenc.framework")
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbisenc.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
endif()

if("${VORBISFILE_LIBRARY}" STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbisfile.framework")
if(VORBISFILE_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbisfile.framework")
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbisfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
endif()

if("${OPENAL_LIBRARY}" STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/OpenAL.framework")
if(OPENAL_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/OpenAL.framework")
install(DIRECTORY "${OPENAL_LIBRARY}" DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
endif()

Expand Down Expand Up @@ -381,7 +393,9 @@ elseif(SFML_OS_IOS)

# since the iOS libraries are built as static, we must install the SFML dependencies
# too so that the end user can easily link them to its final application
install(FILES extlibs/libs-ios/libfreetype.a extlibs/libs-ios/libjpeg.a DESTINATION lib)
if(SFML_BUILD_GRAPHICS)
install(FILES extlibs/libs-ios/libfreetype.a extlibs/libs-ios/libjpeg.a DESTINATION lib)
endif()

elseif(SFML_OS_ANDROID)

Expand Down
42 changes: 27 additions & 15 deletions examples/CMakeLists.txt
@@ -1,18 +1,30 @@

# add the examples subdirectories
add_subdirectory(ftp)
add_subdirectory(opengl)
add_subdirectory(pong)
add_subdirectory(shader)
add_subdirectory(sockets)
add_subdirectory(sound)
add_subdirectory(sound_capture)
add_subdirectory(voip)
add_subdirectory(window)
if(SFML_OS_WINDOWS)
add_subdirectory(win32)
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
add_subdirectory(X11)
elseif(SFML_OS_MACOSX)
add_subdirectory(cocoa)
if(SFML_BUILD_NETWORK)
add_subdirectory(ftp)
add_subdirectory(sockets)
endif()
if(SFML_BUILD_NETWORK AND SFML_BUILD_AUDIO)
add_subdirectory(voip)
endif()
if(SFML_BUILD_AUDIO)
add_subdirectory(sound)
add_subdirectory(sound_capture)
endif()
if(SFML_BUILD_WINDOW)
add_subdirectory(window)
endif()
if(SFML_BUILD_GRAPHICS)
add_subdirectory(opengl)
add_subdirectory(shader)
if(SFML_OS_WINDOWS)
add_subdirectory(win32)
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
add_subdirectory(X11)
elseif(SFML_OS_MACOSX)
add_subdirectory(cocoa)
endif()
endif()
if(SFML_BUILD_GRAPHICS AND SFML_BUILD_AUDIO)
add_subdirectory(pong)
endif()
28 changes: 24 additions & 4 deletions src/SFML/CMakeLists.txt
Expand Up @@ -49,11 +49,31 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules/")
set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")

# add the modules subdirectories

# sfml-system
add_subdirectory(System)

# sfml-main and sfml-activity
if(SFML_OS_WINDOWS OR SFML_OS_ANDROID OR SFML_OS_IOS)
add_subdirectory(Main)
endif()
add_subdirectory(Window)
add_subdirectory(Network)
add_subdirectory(Graphics)
add_subdirectory(Audio)

# sfml-window
if(SFML_BUILD_WINDOW OR SFML_BUILD_GRAPHICS)
add_subdirectory(Window)
endif()

# sfml-network
if(SFML_BUILD_NETWORK)
add_subdirectory(Network)
endif()

# sfml-graphics
if(SFML_BUILD_GRAPHICS)
add_subdirectory(Graphics)
endif()

# sfml-audio
if(SFML_BUILD_AUDIO)
add_subdirectory(Audio)
endif()

0 comments on commit 40cb8cd

Please sign in to comment.