Rewrote cmake scripts
parent
5b7ebd7690
commit
ad6877e19d
246
CMakeLists.txt
246
CMakeLists.txt
|
@ -1,159 +1,85 @@
|
|||
# CMake's built-in Android support requires 3.7
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
cmake_minimum_required(VERSION 3.7) # CMake's built-in Android support requires 3.7
|
||||
else()
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 3.5) # Can be at most 3.5.1 as long as Ubuntu 16.04 is supported
|
||||
endif()
|
||||
|
||||
# Define a macro that helps defining an option
|
||||
macro(tgui_set_option var default type docstring)
|
||||
if(NOT DEFINED ${var})
|
||||
set(${var} ${default})
|
||||
endif()
|
||||
set(${var} ${${var}} CACHE ${type} ${docstring} FORCE)
|
||||
endmacro()
|
||||
|
||||
# Define a macro to add compiler flags
|
||||
macro(tgui_add_cxx_flag flag)
|
||||
string(REGEX REPLACE "\\+" "\\\\+" escapedFlag ${flag})
|
||||
if (NOT (${CMAKE_CXX_FLAGS} MATCHES ".*${escapedFlag}.*"))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" CACHE STRING "C++ compiler flags" FORCE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Use new RPATH behaviors on macOS
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif()
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.9)
|
||||
# Use new RPATH behavior on macOS
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 3.9)
|
||||
cmake_policy(SET CMP0068 NEW)
|
||||
endif()
|
||||
|
||||
macro(tgui_remove_cxx_flag flagToRemove)
|
||||
string(REPLACE " " ";" TGUI_CXX_FLAGS_LIST ${CMAKE_CXX_FLAGS})
|
||||
set(TGUI_TEMP_CXX_FLAGS "")
|
||||
foreach (flag ${TGUI_CXX_FLAGS_LIST})
|
||||
if (NOT (${flag} STREQUAL "${flagToRemove}"))
|
||||
set(TGUI_TEMP_CXX_FLAGS "${TGUI_TEMP_CXX_FLAGS} ${flag}")
|
||||
endif()
|
||||
endforeach(flag)
|
||||
set(CMAKE_CXX_FLAGS "${TGUI_TEMP_CXX_FLAGS}")
|
||||
endmacro()
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Macros.cmake)
|
||||
|
||||
# Set a default build type and module path if none was provided
|
||||
# Set a default build type
|
||||
tgui_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")
|
||||
|
||||
# Set CMAKE_MODULE_PATH to find SFML < 2.5 without manually having to specify a module path
|
||||
if ((NOT DEFINED SFML_DIR OR "${SFML_DIR}" STREQUAL "" OR "${SFML_DIR}" STREQUAL "SFML_DIR-NOTFOUND") AND NOT DEFINED CMAKE_MODULE_PATH)
|
||||
if(NOT SFML_DIR AND NOT CMAKE_MODULE_PATH)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
|
||||
endif()
|
||||
|
||||
# Project name
|
||||
project(tgui)
|
||||
|
||||
# project version
|
||||
SET( MAJOR_VERSION 0 )
|
||||
SET( MINOR_VERSION 8 )
|
||||
SET( PATCH_VERSION 0 )
|
||||
# Project name and version
|
||||
project(TGUI VERSION 0.8.0 LANGUAGES CXX)
|
||||
|
||||
# Include the configuration file
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake)
|
||||
|
||||
# Add an option for choosing the build type (shared or static)
|
||||
if(NOT (SFML_OS_IOS OR SFML_OS_ANDROID))
|
||||
if(NOT TGUI_OS_IOS AND NOT TGUI_OS_ANDROID)
|
||||
tgui_set_option(TGUI_SHARED_LIBS TRUE BOOL "TRUE to build TGUI as a shared library, FALSE to build it as a static library")
|
||||
else()
|
||||
if(SFML_OS_IOS)
|
||||
if(TGUI_OS_IOS)
|
||||
set(TGUI_SHARED_LIBS FALSE)
|
||||
elseif(SFML_OS_ANDROID)
|
||||
elseif(TGUI_OS_ANDROID)
|
||||
set(TGUI_SHARED_LIBS TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Add option to build the examples
|
||||
if(SFML_OS_IOS OR SFML_OS_ANDROID)
|
||||
set(TGUI_BUILD_EXAMPLES FALSE)
|
||||
else()
|
||||
if(NOT TGUI_OS_IOS AND NOT TGUI_OS_ANDROID)
|
||||
tgui_set_option(TGUI_BUILD_EXAMPLES FALSE BOOL "TRUE to build the TGUI examples, FALSE to ignore them")
|
||||
else()
|
||||
set(TGUI_BUILD_EXAMPLES FALSE)
|
||||
endif()
|
||||
|
||||
tgui_set_option(TGUI_BUILD_TESTS FALSE BOOL "TRUE to build the TGUI tests")
|
||||
tgui_set_option(TGUI_BUILD_GUI_BUILDER FALSE BOOL "TRUE to compile the GUI Builder")
|
||||
tgui_set_option(TGUI_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
|
||||
|
||||
# Set compile flags for gcc and clang
|
||||
if (SFML_OS_ANDROID)
|
||||
tgui_remove_cxx_flag(-fno-exceptions)
|
||||
tgui_remove_cxx_flag(-fno-rtti)
|
||||
# Define the install directory for miscellaneous files
|
||||
if(TGUI_OS_WINDOWS OR TGUI_OS_IOS)
|
||||
set(DEFAULT_INSTALL_MISC_DIR .)
|
||||
elseif(TGUI_OS_LINUX OR TGUI_OS_FREEBSD)
|
||||
set(DEFAULT_INSTALL_MISC_DIR share/tgui-${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR})
|
||||
elseif(TGUI_OS_MACOSX)
|
||||
set(DEFAULT_INSTALL_MISC_DIR /usr/local/share/tgui-${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR})
|
||||
elseif(TGUI_OS_ANDROID)
|
||||
set(DEFAULT_INSTALL_MISC_DIR ${CMAKE_ANDROID_NDK}/sources/third_party/tgui)
|
||||
endif()
|
||||
tgui_set_option(TGUI_MISC_INSTALL_PREFIX "${DEFAULT_INSTALL_MISC_DIR}" PATH "Prefix installation path for miscellaneous files")
|
||||
mark_as_advanced(TGUI_MISC_INSTALL_PREFIX)
|
||||
|
||||
# TGUI was only successfully tested on Android with NDK 12b, which did not work when -std=c++1y (or -std=c++14) is defined
|
||||
tgui_add_cxx_flag(-std=c++11)
|
||||
|
||||
tgui_add_cxx_flag(-fexceptions)
|
||||
tgui_add_cxx_flag(-frtti)
|
||||
|
||||
set(TGUI_ACTIVITY_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
elseif(SFML_COMPILER_GCC OR SFML_COMPILER_CLANG)
|
||||
tgui_add_cxx_flag(-Wall)
|
||||
tgui_add_cxx_flag(-Wextra)
|
||||
tgui_add_cxx_flag(-Wshadow)
|
||||
tgui_add_cxx_flag(-Wno-long-long)
|
||||
tgui_add_cxx_flag(-pedantic)
|
||||
|
||||
tgui_remove_cxx_flag(-std=c++14)
|
||||
tgui_remove_cxx_flag(-std=gnu++14)
|
||||
tgui_remove_cxx_flag(-std=c++17)
|
||||
|
||||
if (TGUI_USE_CPP17)
|
||||
tgui_add_cxx_flag(-std=c++17)
|
||||
message(WARNING "The library is being build with c++17 features. Keep in mind that you MUST define TGUI_USE_CPP17 in the project using the library as well.")
|
||||
else()
|
||||
if (SFML_COMPILER_GCC AND SFML_OS_WINDOWS)
|
||||
# gnu++14 instead of c++14 because TDM-GCC 5.1 did not declare _fullpath without enabling GNU extensions (other tested MinGW versions did not require it)
|
||||
tgui_add_cxx_flag(-std=gnu++14)
|
||||
else()
|
||||
# The -std=c++14 flag was added in GCC 4.9 and Clang 3.5
|
||||
tgui_add_cxx_flag(-std=c++14)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# On mac, clang needs another parameter
|
||||
if (SFML_COMPILER_CLANG AND SFML_OS_MACOSX)
|
||||
tgui_add_cxx_flag(-stdlib=libc++)
|
||||
endif()
|
||||
if(TGUI_USE_CPP17)
|
||||
message(WARNING "The library is being build with c++17 features. Keep in mind that you MUST define TGUI_USE_CPP17 in the project using the library as well.")
|
||||
endif()
|
||||
|
||||
# Define an option for choosing between static and dynamic C runtime (VC++ only)
|
||||
if (SFML_OS_WINDOWS)
|
||||
if(TGUI_OS_WINDOWS)
|
||||
tgui_set_option(TGUI_USE_STATIC_STD_LIBS FALSE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs. This option has to match with the one from sfml.")
|
||||
|
||||
# The following combination of flags is not valid
|
||||
if (TGUI_SHARED_LIBS AND TGUI_USE_STATIC_STD_LIBS)
|
||||
if(TGUI_SHARED_LIBS AND TGUI_USE_STATIC_STD_LIBS)
|
||||
message(FATAL_ERROR "TGUI_SHARED_LIBS and TGUI_USE_STATIC_STD_LIBS cannot be used together")
|
||||
endif()
|
||||
|
||||
# Apply it globally by modifying the compiler flags
|
||||
if(SFML_COMPILER_MSVC AND TGUI_USE_STATIC_STD_LIBS)
|
||||
foreach(flag
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Mac OS X specific options
|
||||
if (SFML_OS_MACOSX)
|
||||
if(TGUI_OS_MACOSX)
|
||||
|
||||
# Add an option to build framework instead of dylib (release only)
|
||||
tgui_set_option(TGUI_BUILD_FRAMEWORK FALSE BOOL "TRUE to build TGUI as a framework library (release only), FALSE to build according to TGUI_SHARED_LIBS")
|
||||
|
||||
# Add an option to let the user specify a custom directory for framework installation
|
||||
tgui_set_option(CMAKE_INSTALL_FRAMEWORK_PREFIX "/Library/Frameworks" STRING "Frameworks installation directory")
|
||||
|
||||
# Only the default architecture (i.e. 64-bit) is supported
|
||||
if(CMAKE_OSX_ARCHITECTURES AND NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
|
||||
message(FATAL_ERROR "Only 64-bit architecture is supported")
|
||||
|
@ -163,15 +89,15 @@ if (SFML_OS_MACOSX)
|
|||
# Enable to use of rpath according to CMake Policy CMP0042
|
||||
set(CMAKE_MACOSX_RPATH 1)
|
||||
|
||||
if (TGUI_BUILD_FRAMEWORK)
|
||||
# Frameworks are only available for release (because cmake currently doesn't allow specifying a custom framework name so XXX-d is not possible)
|
||||
if(TGUI_BUILD_FRAMEWORK)
|
||||
# Frameworks are only available for release (because cmake currently doesn't allow specifying a custom framework name so TGUI-d is not possible)
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
message(FATAL_ERROR "CMAKE_BUILD_TYPE should be \"Release\" when TGUI_BUILD_FRAMEWORK is TRUE")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Frameworks only work with TGUI_SHARED_LIBS enabled
|
||||
if (NOT TGUI_SHARED_LIBS)
|
||||
if(NOT TGUI_SHARED_LIBS)
|
||||
message(FATAL_ERROR "TGUI_SHARED_LIBS should be TRUE when TGUI_BUILD_FRAMEWORK is TRUE")
|
||||
return()
|
||||
endif()
|
||||
|
@ -179,10 +105,10 @@ if (SFML_OS_MACOSX)
|
|||
endif()
|
||||
|
||||
# Android options
|
||||
if(SFML_OS_ANDROID)
|
||||
if(TGUI_OS_ANDROID)
|
||||
|
||||
# Make sure there's the android library available
|
||||
if (CMAKE_ANDROID_API LESS 19)
|
||||
if(CMAKE_ANDROID_API LESS 19)
|
||||
message(FATAL_ERROR "Android API level (${CMAKE_ANDROID_API}) must be equal or greater than 19.")
|
||||
endif()
|
||||
|
||||
|
@ -198,9 +124,8 @@ if(SFML_OS_ANDROID)
|
|||
set(LIB_SUFFIX "/${CMAKE_ANDROID_ARCH_ABI}")
|
||||
|
||||
# Pass shared STL configuration (if any)
|
||||
if (CMAKE_ANDROID_STL_TYPE MATCHES "_shared")
|
||||
add_definitions("-DSTL_LIBRARY=${CMAKE_ANDROID_STL_TYPE}")
|
||||
if (NOT CMAKE_ANDROID_STL_TYPE MATCHES "c\\+\\+_shared")
|
||||
if(CMAKE_ANDROID_STL_TYPE MATCHES "_shared")
|
||||
if(NOT CMAKE_ANDROID_STL_TYPE MATCHES "c\\+\\+_shared")
|
||||
message("Android: Using ${CMAKE_ANDROID_STL_TYPE} as STL. Set CMAKE_ANDROID_STL_TYPE to c++_shared, if there are any issues.")
|
||||
endif()
|
||||
else()
|
||||
|
@ -209,8 +134,8 @@ if(SFML_OS_ANDROID)
|
|||
endif()
|
||||
|
||||
# Link SFML in the same way as TGUI, unless SFML_STATIC_LIBRARIES is manually specified
|
||||
if (NOT DEFINED SFML_STATIC_LIBRARIES)
|
||||
if (TGUI_SHARED_LIBS)
|
||||
if(NOT DEFINED SFML_STATIC_LIBRARIES)
|
||||
if(TGUI_SHARED_LIBS)
|
||||
set(SFML_STATIC_LIBRARIES FALSE)
|
||||
else()
|
||||
set(SFML_STATIC_LIBRARIES TRUE)
|
||||
|
@ -219,104 +144,72 @@ endif()
|
|||
|
||||
# Attempt to find the SFML dependencies when linking statically
|
||||
if(NOT TGUI_SHARED_LIBS)
|
||||
if (SFML_ROOT)
|
||||
if (SFML_OS_WINDOWS)
|
||||
if(SFML_ROOT)
|
||||
if(TGUI_OS_WINDOWS)
|
||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${SFML_ROOT}/extlibs/headers")
|
||||
if(ARCH_32BITS)
|
||||
if(SFML_COMPILER_MSVC AND MSVC_VERSION LESS 1900) # older than VC++14
|
||||
if(TGUI_COMPILER_MSVC AND MSVC_VERSION LESS 1900) # older than VC++14
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-msvc/x86")
|
||||
elseif(SFML_COMPILER_MSVC) # VC++14 or newer
|
||||
elseif(TGUI_COMPILER_MSVC) # VC++14 or newer
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-msvc-universal/x86")
|
||||
else() # gcc
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-mingw/x86")
|
||||
endif()
|
||||
elseif(ARCH_64BITS)
|
||||
if(SFML_COMPILER_MSVC AND MSVC_VERSION LESS 1900) # older than VC++14
|
||||
if(TGUI_COMPILER_MSVC AND MSVC_VERSION LESS 1900) # older than VC++14
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-msvc/x64")
|
||||
elseif(SFML_COMPILER_MSVC) # VC++14 or newer
|
||||
elseif(TGUI_COMPILER_MSVC) # VC++14 or newer
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-msvc-universal/x64")
|
||||
else() # gcc
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-mingw/x64")
|
||||
endif()
|
||||
endif()
|
||||
elseif(SFML_OS_MACOSX)
|
||||
elseif(TGUI_OS_MACOSX)
|
||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${SFML_ROOT}/extlibs/headers")
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-osx/lib/")
|
||||
elseif(SFML_OS_ANDROID)
|
||||
elseif(TGUI_OS_ANDROID)
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_ANDROID_NDK}/sources/third_party/sfml/extlibs/lib/${CMAKE_ANDROID_ARCH_ABI}/")
|
||||
elseif(SFML_OS_IOS)
|
||||
elseif(TGUI_OS_IOS)
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${SFML_ROOT}/extlibs/libs-ios/")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find sfml
|
||||
if (SFML_OS_WINDOWS AND SFML_COMPILER_MSVC) # Also look for the main component when using Visual Studio
|
||||
if(TGUI_OS_WINDOWS AND TGUI_COMPILER_MSVC) # Also look for the main component when using Visual Studio
|
||||
find_package(SFML 2 COMPONENTS main graphics window system)
|
||||
elseif (SFML_OS_IOS) # Use the find_host_package macro from the toolchain on iOS
|
||||
elseif(TGUI_OS_IOS) # Use the find_host_package macro from the toolchain on iOS
|
||||
find_host_package(SFML 2 COMPONENTS graphics window system)
|
||||
else()
|
||||
find_package(SFML 2 COMPONENTS graphics window system)
|
||||
endif()
|
||||
|
||||
# FindSFML couldn't find SFML
|
||||
if (NOT SFML_FOUND)
|
||||
# find_package couldn't find SFML
|
||||
if(NOT SFML_FOUND)
|
||||
set(SFML_DIR "" CACHE PATH "Path to SFMLConfig.cmake")
|
||||
set(SFML_ROOT "" CACHE PATH "SFML root directory")
|
||||
message(FATAL_ERROR "CMake couldn't find SFML.\nEither set SFML_DIR to the directory containing SFMLConfig.cmake or set the SFML_ROOT entry to SFML's root directory (containing \"include\" and \"lib\" directories).")
|
||||
endif()
|
||||
|
||||
# Set the path for the libraries
|
||||
set( LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib" )
|
||||
|
||||
# Add the sfml and tgui include directories
|
||||
include_directories( "${PROJECT_SOURCE_DIR}/include" )
|
||||
include_directories( ${SFML_INCLUDE_DIR} )
|
||||
|
||||
if (DEFINED SFML_LIBRARIES)
|
||||
# SFML found via FindSFML.cmake
|
||||
set(TGUI_EXT_LIBS ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
|
||||
else()
|
||||
# SFML found via SFMLConfig.cmake
|
||||
if (SFML_OS_WINDOWS AND SFML_COMPILER_MSVC) # Also look for the main component when using Visual Studio
|
||||
set(TGUI_EXT_LIBS sfml-main sfml-graphics sfml-window sfml-system)
|
||||
else()
|
||||
set(TGUI_EXT_LIBS sfml-graphics sfml-window sfml-system)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SFML_OS_ANDROID)
|
||||
# We need to link to an extra library on android (to use the asset manager)
|
||||
set(TGUI_EXT_LIBS ${TGUI_EXT_LIBS} "-landroid")
|
||||
endif()
|
||||
|
||||
# Generate .gcno files when requested
|
||||
if (TGUI_BUILD_TESTS AND TGUI_USE_GCOV)
|
||||
tgui_add_cxx_flag(-fprofile-arcs)
|
||||
tgui_add_cxx_flag(-ftest-coverage)
|
||||
endif()
|
||||
set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")
|
||||
|
||||
# Jump to the CMakeLists.txt file in the source folder
|
||||
add_subdirectory(src/TGUI)
|
||||
|
||||
# Install the themes on linux
|
||||
if (SFML_OS_LINUX)
|
||||
install( DIRECTORY themes DESTINATION "${INSTALL_MISC_DIR}" )
|
||||
endif()
|
||||
|
||||
# Build the documentation when requested
|
||||
if (TGUI_BUILD_DOC)
|
||||
if(TGUI_BUILD_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
|
||||
# Build the examples if requested
|
||||
if (TGUI_BUILD_EXAMPLES)
|
||||
if(TGUI_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
# Build the tests if requested
|
||||
if (TGUI_BUILD_TESTS)
|
||||
if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||
if(TGUI_BUILD_TESTS)
|
||||
if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||
message(FATAL_ERROR "TGUI_BUILD_TESTS should only be enabled when CMAKE_BUILD_TYPE is Debug")
|
||||
endif()
|
||||
|
||||
|
@ -324,29 +217,30 @@ if (TGUI_BUILD_TESTS)
|
|||
endif()
|
||||
|
||||
# Build the GUI Builder if requested
|
||||
if (TGUI_BUILD_GUI_BUILDER)
|
||||
if(TGUI_BUILD_GUI_BUILDER)
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/gui-builder")
|
||||
endif()
|
||||
|
||||
# Install include files
|
||||
if (NOT TGUI_BUILD_FRAMEWORK)
|
||||
if(NOT TGUI_BUILD_FRAMEWORK)
|
||||
install(DIRECTORY include
|
||||
DESTINATION .
|
||||
COMPONENT devel
|
||||
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl")
|
||||
endif()
|
||||
|
||||
# Install FindTGUI.cmake file
|
||||
if(NOT SFML_OS_ANDROID)
|
||||
install(FILES cmake/Modules/FindTGUI.cmake DESTINATION "${INSTALL_MISC_DIR}/cmake/Modules")
|
||||
# Install miscellaneous files
|
||||
install(FILES license.txt DESTINATION ${TGUI_MISC_INSTALL_PREFIX})
|
||||
install(FILES README.md DESTINATION ${TGUI_MISC_INSTALL_PREFIX})
|
||||
install(DIRECTORY themes DESTINATION "${TGUI_MISC_INSTALL_PREFIX}")
|
||||
if(NOT TGUI_OS_ANDROID)
|
||||
install(FILES cmake/Modules/FindTGUI.cmake DESTINATION "${TGUI_MISC_INSTALL_PREFIX}/cmake/Modules")
|
||||
endif()
|
||||
|
||||
# Install Android.mk so the NDK knows how to set up TGUI
|
||||
if(SFML_OS_ANDROID)
|
||||
if(TGUI_OS_ANDROID)
|
||||
install(FILES Android.mk DESTINATION .)
|
||||
endif()
|
||||
|
||||
# Fix CMake install rules broken for iOS (see http://public.kitware.com/Bug/view.php?id=12506)
|
||||
if(SFML_OS_IOS)
|
||||
install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/\$ENV{CONFIGURATION}/" DESTINATION lib${LIB_SUFFIX})
|
||||
endif()
|
||||
# Generate the TGUIConfig.cmake file
|
||||
tgui_export_target(TGUIConfigExport)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
set(SFML_OS_WINDOWS 1)
|
||||
set(TGUI_OS_WINDOWS 1)
|
||||
|
||||
# detect the architecture (note: this test won't work for cross-compilation)
|
||||
include(CheckTypeSize)
|
||||
|
@ -14,19 +14,19 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|||
return()
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
set(SFML_OS_UNIX 1)
|
||||
set(TGUI_OS_UNIX 1)
|
||||
if(ANDROID)
|
||||
set(SFML_OS_ANDROID 1)
|
||||
set(TGUI_OS_ANDROID 1)
|
||||
else()
|
||||
set(SFML_OS_LINUX 1)
|
||||
set(TGUI_OS_LINUX 1)
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "^k?FreeBSD$")
|
||||
set(SFML_OS_FREEBSD 1)
|
||||
set(TGUI_OS_FREEBSD 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
if(IOS)
|
||||
set(SFML_OS_IOS 1)
|
||||
set(TGUI_OS_IOS 1)
|
||||
else()
|
||||
set(SFML_OS_MACOSX 1)
|
||||
set(TGUI_OS_MACOSX 1)
|
||||
|
||||
# detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.)
|
||||
EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
|
||||
|
@ -37,7 +37,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
|||
endif()
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
|
||||
set(SFML_OS_ANDROID 1)
|
||||
set(TGUI_OS_ANDROID 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported operating system or environment")
|
||||
return()
|
||||
|
@ -49,32 +49,23 @@ endif()
|
|||
if(CMAKE_CXX_COMPILER MATCHES ".*clang[+][+]" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
|
||||
# but there is no other way to detect CLang at the moment
|
||||
set(SFML_COMPILER_CLANG 1)
|
||||
set(TGUI_COMPILER_CLANG 1)
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
|
||||
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
||||
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" TGUI_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(SFML_COMPILER_GCC 1)
|
||||
set(TGUI_COMPILER_GCC 1)
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
||||
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}")
|
||||
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" TGUI_GCC_VERSION "${GCC_VERSION_OUTPUT}")
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION)
|
||||
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
|
||||
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" TGUI_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
|
||||
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
|
||||
if(GCC_MACHINE MATCHES ".*w64.*")
|
||||
set(SFML_COMPILER_GCC_W64 1)
|
||||
set(TGUI_COMPILER_GCC_W64 1)
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
set(SFML_COMPILER_MSVC 1)
|
||||
set(TGUI_COMPILER_MSVC 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported compiler")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# define the install directory for miscellaneous files
|
||||
if(SFML_OS_WINDOWS OR SFML_OS_IOS)
|
||||
set(INSTALL_MISC_DIR .)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
|
||||
set(INSTALL_MISC_DIR share/tgui-${MAJOR_VERSION}.${MINOR_VERSION})
|
||||
elseif(SFML_OS_ANDROID)
|
||||
set(INSTALL_MISC_DIR ${CMAKE_ANDROID_NDK}/sources/third_party/tgui)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
# Macro that helps defining an option
|
||||
macro(tgui_set_option var default type docstring)
|
||||
if(NOT DEFINED ${var})
|
||||
set(${var} ${default})
|
||||
endif()
|
||||
set(${var} ${${var}} CACHE ${type} ${docstring} FORCE)
|
||||
endmacro()
|
||||
|
||||
# Set the compile options used by all targets
|
||||
function(tgui_set_global_compile_flags target)
|
||||
if(TGUI_COMPILER_GCC OR TGUI_COMPILER_CLANG)
|
||||
target_compile_options(${target} PRIVATE -Wall)
|
||||
target_compile_options(${target} PRIVATE -Wextra)
|
||||
target_compile_options(${target} PRIVATE -Wshadow)
|
||||
target_compile_options(${target} PRIVATE -Wno-long-long)
|
||||
target_compile_options(${target} PRIVATE -pedantic)
|
||||
|
||||
set_target_properties(${target} PROPERTIES CXX_STANDARD_REQUIRED ON)
|
||||
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
|
||||
if(TGUI_USE_CPP17)
|
||||
set_target_properties(${target} PROPERTIES CXX_STANDARD 17)
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES CXX_STANDARD 14)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Set the appropriate standard library on each platform for the given target
|
||||
function(tgui_set_stdlib target)
|
||||
# Use libc++ on macOS
|
||||
if(TGUI_OS_MACOSX)
|
||||
if(${CMAKE_GENERATOR} MATCHES "Xcode")
|
||||
set_property(TARGET ${target} PROPERTY XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
||||
else()
|
||||
target_compile_options(${target} PRIVATE "-stdlib=libc++")
|
||||
target_link_libraries(${target} PRIVATE "-stdlib=libc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Apply the TGUI_USE_STATIC_STD_LIBS option on windows
|
||||
if(TGUI_OS_WINDOWS)
|
||||
if(TGUI_COMPILER_MSVC AND TGUI_USE_STATIC_STD_LIBS)
|
||||
foreach(flag
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
elseif(TGUI_COMPILER_GCC)
|
||||
if(TGUI_USE_STATIC_STD_LIBS AND NOT TGUI_COMPILER_GCC_TDM)
|
||||
target_link_libraries(${target} PRIVATE "-static-libgcc" "-static-libstdc++")
|
||||
elseif(NOT TGUI_USE_STATIC_STD_LIBS AND TGUI_COMPILER_GCC_TDM)
|
||||
target_link_libraries(${target} PRIVATE "-shared-libgcc" "-shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Generate a TGUIConfig.cmake file (and associated files)
|
||||
function(tgui_export_target export_name)
|
||||
include(CMakePackageConfigHelpers)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.11)
|
||||
set(CVF_VERSION ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH})
|
||||
configure_file("${PROJECT_SOURCE_DIR}/cmake/TGUIConfigVersion.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/TGUIConfigVersion.cmake" @ONLY)
|
||||
else()
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/TGUIConfigVersion.cmake"
|
||||
VERSION ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH}
|
||||
COMPATIBILITY SameMinorVersion)
|
||||
endif()
|
||||
|
||||
if (TGUI_SHARED_LIBS)
|
||||
set(targets_config_filename TGUISharedTargets.cmake)
|
||||
else()
|
||||
set(targets_config_filename TGUIStaticTargets.cmake)
|
||||
endif()
|
||||
|
||||
export(EXPORT ${export_name}
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${targets_config_filename}")
|
||||
|
||||
if (TGUI_BUILD_FRAMEWORK)
|
||||
set(config_package_location "TGUI.framework/Resources/CMake")
|
||||
else()
|
||||
set(config_package_location lib/cmake/TGUI)
|
||||
endif()
|
||||
configure_package_config_file("${PROJECT_SOURCE_DIR}/cmake/TGUIConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/TGUIConfig.cmake"
|
||||
INSTALL_DESTINATION "${config_package_location}")
|
||||
|
||||
install(EXPORT ${export_name}
|
||||
FILE ${targets_config_filename}
|
||||
DESTINATION ${config_package_location})
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/TGUIConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/TGUIConfigVersion.cmake"
|
||||
DESTINATION ${config_package_location}
|
||||
COMPONENT devel)
|
||||
endfunction()
|
|
@ -0,0 +1,95 @@
|
|||
# This script provides the TGUI libraries as imported targets
|
||||
# ===========================================================
|
||||
#
|
||||
# Usage
|
||||
# -----
|
||||
#
|
||||
# Examples:
|
||||
# find_package(TGUI 0.8)
|
||||
# find_package(TGUI 0.8 REQUIRED)
|
||||
#
|
||||
# By default, the dynamic libraries of TGUI will be found. To find the static ones instead,
|
||||
# you must set the TGUI_STATIC_LIBRARIES variable to TRUE before calling find_package(TGUI ...).
|
||||
# example:
|
||||
# set(TGUI_STATIC_LIBRARIES TRUE)
|
||||
# find_package(TGUI 0.8 REQUIRED)
|
||||
#
|
||||
# On macOS by default CMake will search for frameworks. If you want to use static libraries and have installed
|
||||
# both TGUI frameworks and TGUI static libraries, your must set CMAKE_FIND_FRAMEWORK to "NEVER" or "LAST"
|
||||
# in addition to setting TGUI_STATIC_LIBRARIES to TRUE. Otherwise CMake will check the frameworks bundle config and
|
||||
# fail after finding out that it does not provide static libraries. Please refer to CMake documentation for more details.
|
||||
#
|
||||
# Additionally, keep in mind that TGUI frameworks are only available as release libraries unlike dylibs which
|
||||
# are available for both release and debug modes.
|
||||
#
|
||||
# If TGUI is not installed in a standard path, you can use the TGUI_DIR CMake variable
|
||||
# to tell CMake where TGUI's config file is located (PREFIX/lib/cmake/TGUI for a library-based installation,
|
||||
# and PREFIX/TGUI.framework/Resources/CMake on macOS for a framework-based installation).
|
||||
#
|
||||
# Output
|
||||
# ------
|
||||
#
|
||||
# This script defines the following variable:
|
||||
# - TGUI_FOUND: true if all the required modules are found
|
||||
#
|
||||
# And the following target:
|
||||
# - tgui
|
||||
#
|
||||
# The TGUI target is the same for both Debug and Release build configurations and will automatically provide
|
||||
# correct settings based on your currently active build configuration. The TGUI target name also does not change
|
||||
# when using dynamic or static TGUI libraries.
|
||||
#
|
||||
# example:
|
||||
# find_package(TGUI 0.8 REQUIRED)
|
||||
# add_executable(myapp ...)
|
||||
# target_link_libraries(myapp tgui)
|
||||
|
||||
set(FIND_TGUI_PATHS
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../.."
|
||||
${TGUI_ROOT}
|
||||
$ENV{TGUI_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt)
|
||||
|
||||
# Choose which target definitions must be imported
|
||||
if (TGUI_STATIC_LIBRARIES)
|
||||
set(TGUI_IS_FRAMEWORK_INSTALL "@TGUI_BUILD_FRAMEWORKS@")
|
||||
if (TGUI_IS_FRAMEWORK_INSTALL)
|
||||
message(WARNING "Static frameworks are not supported by TGUI. Clear TGUI_DIR cache entry, \
|
||||
and either change TGUI_STATIC_LIBRARIES or CMAKE_FIND_FRAMEWORK before calling find_package(TGUI)")
|
||||
endif()
|
||||
set(config_name "Static")
|
||||
else()
|
||||
set(config_name "Shared")
|
||||
endif()
|
||||
set(targets_config_file "${CMAKE_CURRENT_LIST_DIR}/TGUI${config_name}Targets.cmake")
|
||||
|
||||
# Generate imported targets for TGUI
|
||||
if (EXISTS "${targets_config_file}")
|
||||
# Set TGUI_FOUND to TRUE by default, may be overwritten by one of the includes below
|
||||
set(TGUI_FOUND TRUE)
|
||||
include("${targets_config_file}")
|
||||
else()
|
||||
set(FIND_TGUI_ERROR "Requested TGUI configuration (${config_name}) was not found")
|
||||
set(TGUI_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
if (NOT TGUI_FOUND)
|
||||
if(TGUI_FIND_REQUIRED)
|
||||
# fatal error
|
||||
message(FATAL_ERROR "${FIND_TGUI_ERROR}")
|
||||
elseif(NOT TGUI_FIND_QUIETLY)
|
||||
# error but continue
|
||||
message(STATUS "${FIND_TGUI_ERROR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (TGUI_FOUND AND NOT TGUI_FIND_QUIETLY)
|
||||
message(STATUS "Found TGUI @TGUI_VERSION_MAJOR@.@TGUI_VERSION_MINOR@.@TGUI_VERSION_PATCH@ in ${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif()
|
|
@ -0,0 +1,53 @@
|
|||
# This file was taken from CMake 3.11 and is provided here in order to use it while using older CMake versions
|
||||
|
||||
# # This is a basic version file for the Config-mode of find_package().
|
||||
# It is used by write_basic_package_version_file() as input file for configure_file()
|
||||
# to create a version-file which can be installed along a config.cmake file.
|
||||
#
|
||||
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
|
||||
# the requested version string are exactly the same and it sets
|
||||
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
|
||||
# but only if the requested major and minor versions are the same as the current
|
||||
# one.
|
||||
# The variable CVF_VERSION must be set before calling configure_file().
|
||||
|
||||
|
||||
set(PACKAGE_VERSION "@CVF_VERSION@")
|
||||
|
||||
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
|
||||
if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.([0-9]+)")
|
||||
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}")
|
||||
else()
|
||||
set(CVF_VERSION_MAJOR "@CVF_VERSION@")
|
||||
set(CVF_VERSION_MINOR "")
|
||||
endif()
|
||||
|
||||
if((PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) AND
|
||||
(PACKAGE_FIND_VERSION_MINOR STREQUAL CVF_VERSION_MINOR))
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
endif()
|
||||
|
||||
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
||||
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
|
||||
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
|
||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
endif()
|
||||
|
|
@ -48,10 +48,10 @@ add_custom_target(doc ALL
|
|||
|
||||
# setup install rules
|
||||
install(DIRECTORY ${DOXYGEN_OUTPUT_DIR}/html
|
||||
DESTINATION ${INSTALL_MISC_DIR}/doc
|
||||
DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/doc
|
||||
COMPONENT doc)
|
||||
if(DOXYGEN_HHC_PROGRAM)
|
||||
install(FILES ${DOXYGEN_OUTPUT_DIR}/tgui.chm
|
||||
DESTINATION ${INSTALL_MISC_DIR}/doc
|
||||
DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/doc
|
||||
COMPONENT doc)
|
||||
endif()
|
||||
|
|
|
@ -5,27 +5,22 @@ macro(tgui_add_example target)
|
|||
# parse the arguments
|
||||
cmake_parse_arguments(THIS "" "" "SOURCES" ${ARGN})
|
||||
|
||||
# Make a GUI application on windows (so without the command line)
|
||||
if(SFML_OS_WINDOWS)
|
||||
# Make a GUI application on windows (without having the command line window)
|
||||
if(TGUI_OS_WINDOWS)
|
||||
set(GUI_TYPE WIN32)
|
||||
target_link_libraries(${target} PRIVATE sfml-main)
|
||||
endif()
|
||||
|
||||
add_executable(${target} ${THIS_SOURCES})
|
||||
target_link_libraries(${target} ${PROJECT_NAME} ${TGUI_EXT_LIBS})
|
||||
add_executable(${target} ${GUI_TYPE} ${THIS_SOURCES})
|
||||
target_link_libraries(${target} PRIVATE tgui)
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the TGUI_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(TGUI_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT TGUI_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
tgui_set_global_compile_flags(${target})
|
||||
tgui_set_stdlib(${target})
|
||||
|
||||
# Add the install rule for the executable
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples
|
||||
BUNDLE DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples)
|
||||
RUNTIME DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/examples/${target} COMPONENT examples
|
||||
BUNDLE DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/examples/${target} COMPONENT examples)
|
||||
|
||||
endmacro()
|
||||
|
||||
|
@ -35,5 +30,5 @@ add_subdirectory(scalable_login_screen)
|
|||
|
||||
# install the examples
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/examples/"
|
||||
DESTINATION "${INSTALL_MISC_DIR}/examples/"
|
||||
DESTINATION "${TGUI_MISC_INSTALL_PREFIX}/examples/"
|
||||
COMPONENT examples)
|
||||
|
|
|
@ -10,8 +10,14 @@ set(GUI_BUILDER_SOURCES
|
|||
include/WidgetProperties.hpp
|
||||
)
|
||||
|
||||
add_executable(gui-builder ${GUI_BUILDER_SOURCES})
|
||||
target_link_libraries(gui-builder ${PROJECT_NAME} ${TGUI_EXT_LIBS})
|
||||
# Make a GUI application on windows (without having the command line window)
|
||||
if(TGUI_OS_WINDOWS)
|
||||
set(GUI_TYPE WIN32)
|
||||
target_link_libraries(gui-builder PRIVATE sfml-main)
|
||||
endif()
|
||||
|
||||
add_executable(gui-builder ${GUI_TYPE} ${GUI_BUILDER_SOURCES})
|
||||
target_link_libraries(gui-builder PRIVATE tgui)
|
||||
target_include_directories(gui-builder PRIVATE include)
|
||||
|
||||
# Copy the executable to the gui-builder folder
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#ifdef SFML_SYSTEM_WINDOWS
|
||||
|
||||
// Windows compilers need specific (and different) keywords for export and import
|
||||
#ifdef tgui_EXPORTS
|
||||
#ifdef TGUI_EXPORTS
|
||||
#define TGUI_API __declspec(dllexport)
|
||||
#else
|
||||
#define TGUI_API __declspec(dllimport)
|
||||
|
|
|
@ -4,29 +4,21 @@ add_library(tgui-activity SHARED TGUIActivity.cpp)
|
|||
# Define the export symbol of the module
|
||||
string(REPLACE "-" "_" NAME_UPPER "tgui-activity")
|
||||
string(TOUPPER "${NAME_UPPER}" NAME_UPPER)
|
||||
set_target_properties(tgui-activity PROPERTIES DEFINE_SYMBOL ${NAME_UPPER}_EXPORTS)
|
||||
target_compile_definitions(tgui-activity PRIVATE ${NAME_UPPER}_EXPORTS)
|
||||
|
||||
# Add a -d suffix when in debug mode
|
||||
set_target_properties(tgui-activity PROPERTIES DEBUG_POSTFIX -d)
|
||||
|
||||
# If using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default (exported ones are explicitly marked)
|
||||
if((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3"))
|
||||
set_target_properties(tgui-activity PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
# Hide public symbols by default (exported ones are explicitly marked)
|
||||
if(TGUI_COMPILER_GCC OR TGUI_COMPILER_CLANG)
|
||||
target_compile_options(tgui-activity PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
# tgui-activity library is our bootstrap activity and must not depend on stlport_shared (otherwise Android will fail to load it)
|
||||
if (SFML_OS_ANDROID)
|
||||
set_target_properties(tgui-activity PROPERTIES COMPILE_FLAGS -fpermissive)
|
||||
set_target_properties(tgui-activity PROPERTIES LINK_FLAGS "-landroid -llog")
|
||||
tgui_set_global_compile_flags(tgui-activity)
|
||||
target_compile_definitions(tgui-activity PRIVATE STL_LIBRARY=${CMAKE_ANDROID_STL_TYPE})
|
||||
target_compile_options(tgui-activity PRIVATE -fpermissive)
|
||||
target_link_libraries(tgui-activity PRIVATE android log)
|
||||
|
||||
# Restore the original compiler flags
|
||||
set(CMAKE_CXX_FLAGS "${TGUI_ACTIVITY_CMAKE_CXX_FLAGS}" CACHE STRING "C++ compiler flags" FORCE)
|
||||
|
||||
# This is a workaround to compile tgui-activity without stlport_shared as dependency
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
endif()
|
||||
|
||||
# Install rule
|
||||
install(TARGETS tgui-activity
|
||||
RUNTIME DESTINATION bin COMPONENT bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
|
||||
|
|
|
@ -82,16 +82,16 @@ set(TGUI_SRC
|
|||
Widgets/VerticalLayout.cpp
|
||||
)
|
||||
|
||||
if (TGUI_OPTIMIZE_SINGLE_BUILD)
|
||||
if(TGUI_OPTIMIZE_SINGLE_BUILD)
|
||||
list(LENGTH TGUI_SRC fileCount)
|
||||
if (TGUI_OPTIMIZE_SINGLE_BUILD_THREADS)
|
||||
if(TGUI_OPTIMIZE_SINGLE_BUILD_THREADS)
|
||||
set(threads ${TGUI_OPTIMIZE_SINGLE_BUILD_THREADS})
|
||||
else()
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(threads)
|
||||
endif()
|
||||
|
||||
if (${threads} LESS ${fileCount})
|
||||
if(${threads} LESS ${fileCount})
|
||||
math(EXPR threads "(${threads} / 2) + 1")
|
||||
math(EXPR fileCountMinusOne "${fileCount} - 1")
|
||||
math(EXPR threadsMinusOne "${threads} - 1")
|
||||
|
@ -108,110 +108,133 @@ if (TGUI_OPTIMIZE_SINGLE_BUILD)
|
|||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if (SFML_COMPILER_MSVC)
|
||||
add_compile_options("/bigobj")
|
||||
endif()
|
||||
|
||||
set(TGUI_SRC ${NEW_TGUI_SRC})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Determine library suffixes depending on static/shared configuration
|
||||
if(TGUI_SHARED_LIBS)
|
||||
add_library(${PROJECT_NAME} SHARED ${TGUI_SRC})
|
||||
set_target_properties( ${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX -d )
|
||||
add_library(tgui SHARED ${TGUI_SRC})
|
||||
set_target_properties(tgui PROPERTIES DEFINE_SYMBOL TGUI_EXPORTS)
|
||||
set_target_properties(tgui PROPERTIES DEBUG_POSTFIX -d)
|
||||
|
||||
# Set the version and soversion of the target (for compatible systems -- mostly Linuxes)
|
||||
# Except for Android which strips soversion suffixes
|
||||
if(NOT SFML_OS_ANDROID)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
|
||||
if(NOT TGUI_OS_ANDROID)
|
||||
set_target_properties(tgui PROPERTIES SOVERSION ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH})
|
||||
set_target_properties(tgui PROPERTIES VERSION ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH})
|
||||
endif()
|
||||
|
||||
# The library should be linked to sfml, unless you are on linux
|
||||
if (NOT SFML_OS_LINUX)
|
||||
target_link_libraries( ${PROJECT_NAME} ${TGUI_EXT_LIBS} )
|
||||
|
||||
# on Windows/gcc get rid of "lib" prefix for shared libraries,
|
||||
# and transform the ".dll.a" suffix into ".a" for import libraries
|
||||
if (SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES IMPORT_SUFFIX ".a")
|
||||
endif()
|
||||
# on Windows/gcc get rid of "lib" prefix for shared libraries,
|
||||
# and transform the ".dll.a" suffix into ".a" for import libraries
|
||||
if(TGUI_OS_WINDOWS AND TGUI_COMPILER_GCC)
|
||||
set_target_properties(tgui PROPERTIES PREFIX "")
|
||||
set_target_properties(tgui PROPERTIES IMPORT_SUFFIX ".a")
|
||||
endif()
|
||||
|
||||
else()
|
||||
add_library(${PROJECT_NAME} STATIC ${TGUI_SRC})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX -s-d)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES RELEASE_POSTFIX -s)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES MINSIZEREL_POSTFIX -s)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX -s)
|
||||
add_library(tgui STATIC ${TGUI_SRC})
|
||||
set_target_properties(tgui PROPERTIES DEBUG_POSTFIX -s-d)
|
||||
set_target_properties(tgui PROPERTIES RELEASE_POSTFIX -s)
|
||||
set_target_properties(tgui PROPERTIES MINSIZEREL_POSTFIX -s)
|
||||
set_target_properties(tgui PROPERTIES RELWITHDEBINFO_POSTFIX -s)
|
||||
endif()
|
||||
|
||||
tgui_set_global_compile_flags(tgui)
|
||||
tgui_set_stdlib(tgui)
|
||||
|
||||
if(TGUI_OPTIMIZE_SINGLE_BUILD AND TGUI_COMPILER_MSVC)
|
||||
target_compile_options(tgui PRIVATE /bigobj)
|
||||
endif()
|
||||
|
||||
# Add <project>/include as public include directory
|
||||
target_include_directories(tgui PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
||||
if (TGUI_BUILD_FRAMEWORK)
|
||||
target_include_directories(tgui INTERFACE $<INSTALL_INTERFACE:TGUI.framework>)
|
||||
else()
|
||||
target_include_directories(tgui INTERFACE $<INSTALL_INTERFACE:include>)
|
||||
endif()
|
||||
|
||||
# Link to SFML
|
||||
if(DEFINED SFML_LIBRARIES)
|
||||
# SFML found via FindSFML.cmake
|
||||
target_include_directories(tgui PUBLIC ${SFML_INCLUDE_DIR})
|
||||
target_link_libraries(tgui PUBLIC ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
|
||||
else()
|
||||
# SFML found via SFMLConfig.cmake
|
||||
target_link_libraries(tgui PUBLIC sfml-graphics)
|
||||
endif()
|
||||
|
||||
# define TGUI_USE_CPP17 if requested
|
||||
if(TGUI_USE_CPP17)
|
||||
target_compile_definitions(tgui PUBLIC TGUI_USE_CPP17)
|
||||
endif()
|
||||
|
||||
# We need to link to an extra library on android (to use the asset manager)
|
||||
if(TGUI_OS_ANDROID)
|
||||
target_link_libraries(tgui PRIVATE android)
|
||||
endif()
|
||||
|
||||
# Generate .gcno files when requested
|
||||
if(TGUI_BUILD_TESTS AND TGUI_USE_GCOV)
|
||||
target_compile_options(tgui PRIVATE -fprofile-arcs)
|
||||
target_compile_options(tgui PRIVATE -ftest-coverage)
|
||||
endif()
|
||||
|
||||
# Enable automatic reference counting on iOS
|
||||
if (SFML_OS_IOS)
|
||||
if(TGUI_OS_IOS)
|
||||
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
||||
endif()
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the TGUI_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(TGUI_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT TGUI_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# if using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
|
||||
# (exported ones are explicitely marked)
|
||||
if(NOT SFML_OS_WINDOWS AND ((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3")))
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
# Hide public symbols by default (exported ones are explicitly marked)
|
||||
if(TGUI_COMPILER_GCC OR TGUI_COMPILER_CLANG)
|
||||
target_compile_options(tgui PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
# Build frameworks or dylibs
|
||||
if(SFML_OS_MACOSX AND TGUI_SHARED_LIBS)
|
||||
if(TGUI_OS_MACOSX AND TGUI_SHARED_LIBS)
|
||||
if(TGUI_BUILD_FRAMEWORK)
|
||||
# Adapt target to build frameworks instead of dylibs
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
set_target_properties(tgui PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.tgui.${PROJECT_NAME}
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
|
||||
FRAMEWORK_VERSION ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.tgui.tgui
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH})
|
||||
|
||||
# Install the header files to the framework
|
||||
add_custom_command(TARGET ${PROJECT_NAME}
|
||||
add_custom_command(TARGET tgui
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${PROJECT_NAME}>/Headers
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/include/TGUI $<TARGET_FILE_DIR:${PROJECT_NAME}>/Headers
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}/Headers $<TARGET_FILE_DIR:${PROJECT_NAME}>/../../Headers)
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:tgui>/Headers
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/include/TGUI $<TARGET_FILE_DIR:tgui>/Headers
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/${TGUI_VERSION_MAJOR}.${TGUI_VERSION_MINOR}.${TGUI_VERSION_PATCH}/Headers $<TARGET_FILE_DIR:tgui>/../../Headers)
|
||||
|
||||
# The framework has to be with a capital letter (because it includes the header files which must be found in a "TGUI" directory)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME TGUI)
|
||||
set_target_properties(tgui PROPERTIES OUTPUT_NAME TGUI)
|
||||
endif()
|
||||
|
||||
# Adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle but only if cmake rpath options aren't set
|
||||
if (NOT CMAKE_SKIP_RPATH AND NOT CMAKE_SKIP_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH AND NOT CMAKE_INSTALL_NAME_DIR)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_NAME_DIR "@rpath")
|
||||
if (NOT CMAKE_SKIP_BUILD_RPATH)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.9)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
if(NOT CMAKE_SKIP_RPATH AND NOT CMAKE_SKIP_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH AND NOT CMAKE_INSTALL_NAME_DIR)
|
||||
set_target_properties(tgui PROPERTIES INSTALL_NAME_DIR "@rpath")
|
||||
if(NOT CMAKE_SKIP_BUILD_RPATH)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.9)
|
||||
set_target_properties(tgui PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
else()
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE)
|
||||
set_target_properties(tgui PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Build tgui-activity on android
|
||||
if(TGUI_OS_ANDROID)
|
||||
add_subdirectory(Android)
|
||||
endif()
|
||||
|
||||
# Install library
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
install(TARGETS tgui EXPORT TGUIConfigExport
|
||||
RUNTIME DESTINATION bin COMPONENT bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin
|
||||
FRAMEWORK DESTINATION . COMPONENT devel
|
||||
)
|
||||
|
||||
# Build tgui-activity on android
|
||||
if (SFML_OS_ANDROID)
|
||||
add_subdirectory(Android)
|
||||
endif()
|
||||
|
|
|
@ -83,25 +83,19 @@ if (TGUI_OPTIMIZE_SINGLE_BUILD OR TGUI_OPTIMIZE_TESTS_SINGLE_BUILD)
|
|||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if (SFML_COMPILER_MSVC)
|
||||
add_compile_options("/bigobj")
|
||||
endif()
|
||||
|
||||
set(TEST_SOURCES ${NEW_TEST_SOURCES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(tests ${TEST_SOURCES})
|
||||
target_include_directories(tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
target_link_libraries(tests ${PROJECT_NAME} ${TGUI_EXT_LIBS})
|
||||
target_link_libraries(tests PRIVATE tgui)
|
||||
|
||||
# For gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(tests PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(tests PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
tgui_set_global_compile_flags(tests)
|
||||
tgui_set_stdlib(tests)
|
||||
|
||||
if(TGUI_OPTIMIZE_SINGLE_BUILD AND TGUI_COMPILER_MSVC)
|
||||
target_compile_options(tests PRIVATE /bigobj)
|
||||
endif()
|
||||
|
||||
# Copy the resources folder to the build directory to execute the tests without installing them
|
||||
|
@ -115,13 +109,13 @@ add_custom_command(TARGET tests
|
|||
|
||||
# Add the install rule for the executable
|
||||
install(TARGETS tests
|
||||
RUNTIME DESTINATION ${INSTALL_MISC_DIR}/tests/ COMPONENT tests
|
||||
BUNDLE DESTINATION ${INSTALL_MISC_DIR}/tests/ COMPONENT tests)
|
||||
RUNTIME DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/tests/ COMPONENT tests
|
||||
BUNDLE DESTINATION ${TGUI_MISC_INSTALL_PREFIX}/tests/ COMPONENT tests)
|
||||
|
||||
# Install the tests
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/tests/resources"
|
||||
DESTINATION "${INSTALL_MISC_DIR}/tests"
|
||||
DESTINATION "${TGUI_MISC_INSTALL_PREFIX}/tests"
|
||||
COMPONENT tests)
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/themes/"
|
||||
DESTINATION "${INSTALL_MISC_DIR}/tests/resources"
|
||||
DESTINATION "${TGUI_MISC_INSTALL_PREFIX}/tests/resources"
|
||||
COMPONENT tests)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
project(TGUI-CMake-test)
|
||||
|
||||
add_executable(TguiTest main.cpp)
|
||||
|
||||
find_package(SFML 2 COMPONENTS graphics window system REQUIRED)
|
||||
find_package(TGUI REQUIRED)
|
||||
target_link_libraries(TguiTest PRIVATE tgui sfml-graphics)
|
|
@ -0,0 +1,7 @@
|
|||
#include <TGUI/TGUI.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
sf::RenderTexture target;
|
||||
tgui::Gui gui{target};
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
set -e
|
||||
|
||||
export SFML_ROOT=$HOME/SFML_LINUX
|
||||
export BUILD_FOLDER=build_gcc-$CXX
|
||||
|
||||
git clone --depth 1 https://github.com/SFML/SFML
|
||||
cd SFML
|
||||
|
@ -24,8 +25,14 @@ else
|
|||
fi
|
||||
cd ..
|
||||
|
||||
mkdir build_gcc-$CXX
|
||||
cd build_gcc-$CXX
|
||||
mkdir $BUILD_FOLDER
|
||||
cd $BUILD_FOLDER
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DTGUI_BUILD_EXAMPLES=TRUE -DTGUI_BUILD_GUI_BUILDER=TRUE -DTGUI_OPTIMIZE_SINGLE_BUILD=TRUE -DTGUI_OPTIMIZE_SINGLE_BUILD_THREADS=2 ..
|
||||
make -j2
|
||||
cd ..
|
||||
|
||||
# Test the TGUIConfig.cmake file
|
||||
cd tests/cmake
|
||||
cmake -DSFML_DIR=$SFML_ROOT -DTGUI_DIR=$TRAVIS_BUILD_DIR/$BUILD_FOLDER .
|
||||
./TguiTest
|
||||
cd ../..
|
||||
|
|
Loading…
Reference in New Issue