mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Big cmake changes (#1514)
* Delete emscripten.cmake This file is not needed at this point. EMSDK provides a toolchain file that has a lot more things in it and is better supported. Project currently works fine with the documentation provided in Emscripten SDK on how to build projects. * First pass file separation. The main two files are cleaner now. Only important things can be seen. Major changes include: - raylib_static is now the alias instead of raylib - Repeating segments are removed and pulled into separate files into <root>/cmake - File is reordered to make more sense - Installs are better structured - Library is build into an output directory "raylib" instead of "src" - All public header files are now set as a public header file - Source files need to be listed (it is a bad practice to capture them using wildcards and file globs) - CMakeLists are better commented * Second pass on the example dirs. They are quite complex so I'm more hesitant to do major changes. Also it works pretty well. Noticed that I forgot one of the seperated files and added it into src/CMakeLists.txt. * Returned the header copy as it was convenient to have the public headers copied. * A better description to the variable RAYLIB_IS_MAIN Co-authored-by: Rob Loach <robloach@gmail.com> * Remove debug message Co-authored-by: Rob Loach <robloach@gmail.com> * Improvements based on review. * Simplify the install condition to not be platform specific as it was before. Co-authored-by: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> * Remove some CMAKE variables as they don't affect the build in any way Co-authored-by: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Co-authored-by: Rob Loach <robloach@gmail.com> Co-authored-by: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com>
This commit is contained in:
@ -1,326 +1,132 @@
|
||||
# Setup the project and settings
|
||||
project(raylib C)
|
||||
include(GNUInstallDirs)
|
||||
include(JoinPaths)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
||||
|
||||
set(PROJECT_VERSION 3.5.0)
|
||||
set(API_VERSION 351)
|
||||
|
||||
include("CMakeOptions.txt")
|
||||
include(BuildType)
|
||||
configure_file(config.h.in ${CMAKE_BINARY_DIR}/cmake/config.h)
|
||||
include_directories(${CMAKE_BINARY_DIR} .)
|
||||
include(GNUInstallDirs)
|
||||
include(JoinPaths)
|
||||
|
||||
# Sets build type if not set by now
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
if(RAYLIB_IS_MAIN)
|
||||
set(default_build_type Debug)
|
||||
endif()
|
||||
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
# Get the sources together
|
||||
file(GLOB raylib_sources *.c)
|
||||
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/rglfw.c)
|
||||
set(raylib_public_headers
|
||||
raylib.h
|
||||
rlgl.h
|
||||
physac.h
|
||||
raymath.h
|
||||
raudio.h
|
||||
)
|
||||
|
||||
if(USE_EXTERNAL_GLFW STREQUAL "ON")
|
||||
find_package(glfw3 3.2.1 REQUIRED)
|
||||
elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
|
||||
find_package(glfw3 3.2.1 QUIET)
|
||||
endif()
|
||||
if (glfw3_FOUND)
|
||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
||||
endif()
|
||||
set(raylib_sources
|
||||
core.c
|
||||
models.c
|
||||
shapes.c
|
||||
text.c
|
||||
textures.c
|
||||
utils.c
|
||||
)
|
||||
|
||||
# Explicitly check against "ON", because USE_EXTERNAL_GLFW is a tristate option
|
||||
if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MATCHES "Desktop")
|
||||
MESSAGE(STATUS "Using raylib's GLFW")
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
|
||||
set(GLFW_USE_WAYLAND ${USE_WAYLAND} CACHE BOOL "" FORCE)
|
||||
# cmake/GlfwImport.cmake handles the details around the inclusion of glfw
|
||||
include(GlfwImport)
|
||||
|
||||
add_subdirectory(external/glfw)
|
||||
|
||||
list(APPEND raylib_sources $<TARGET_OBJECTS:glfw_objlib>)
|
||||
include_directories(BEFORE SYSTEM external/glfw/include)
|
||||
else()
|
||||
MESSAGE(STATUS "Using external GLFW")
|
||||
set(GLFW_PKG_DEPS glfw3)
|
||||
endif()
|
||||
if (USE_AUDIO)
|
||||
MESSAGE(STATUS "Audio Backend: miniaudio")
|
||||
list(APPEND raylib_sources raudio.c)
|
||||
else ()
|
||||
MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)")
|
||||
endif ()
|
||||
|
||||
add_definitions("-DRAYLIB_CMAKE=1")
|
||||
include(LibraryConfigurations)
|
||||
|
||||
if(USE_AUDIO)
|
||||
MESSAGE(STATUS "Audio Backend: miniaudio")
|
||||
set(sources ${raylib_sources})
|
||||
else()
|
||||
MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)")
|
||||
set(RAYLIB_MODULE_AUDIO 0)
|
||||
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/raudio.c)
|
||||
set(sources ${raylib_sources})
|
||||
endif()
|
||||
|
||||
### Config options ###
|
||||
# Translate the config options to what raylib wants
|
||||
if(${PLATFORM} MATCHES "Desktop")
|
||||
set(PLATFORM_CPP "PLATFORM_DESKTOP")
|
||||
|
||||
if(APPLE)
|
||||
# Need to force OpenGL 3.3 on OS X
|
||||
# See: https://github.com/raysan5/raylib/issues/341
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
|
||||
find_library(OPENGL_LIBRARY OpenGL)
|
||||
set(LIBS_PRIVATE ${OPENGL_LIBRARY})
|
||||
link_libraries("${LIBS_PRIVATE}")
|
||||
if (NOT CMAKE_SYSTEM STRLESS "Darwin-18.0.0")
|
||||
add_definitions(-DGL_SILENCE_DEPRECATION)
|
||||
MESSAGE(AUTHOR_WARNING "OpenGL is deprecated starting with macOS 10.14 (Mojave)!")
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} winmm)
|
||||
else()
|
||||
find_library(pthread NAMES pthread)
|
||||
find_package(OpenGL QUIET)
|
||||
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
||||
set(OPENGL_LIBRARIES "GL")
|
||||
endif()
|
||||
|
||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
||||
find_library(OSS_LIBRARY ossaudio)
|
||||
endif()
|
||||
|
||||
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
||||
endif()
|
||||
|
||||
elseif(${PLATFORM} MATCHES "Web")
|
||||
set(PLATFORM_CPP "PLATFORM_WEB")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||
|
||||
set(CMAKE_C_FLAGS "-s USE_GLFW=3 -s ASSERTIONS=1 --profiling")
|
||||
|
||||
# Change the name of the output library
|
||||
|
||||
elseif(${PLATFORM} MATCHES "Android")
|
||||
set(PLATFORM_CPP "PLATFORM_ANDROID")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||
include(AddIfFlagCompiles)
|
||||
add_if_flag_compiles(-ffunction-sections CMAKE_C_FLAGS)
|
||||
add_if_flag_compiles(-funwind-tables CMAKE_C_FLAGS)
|
||||
add_if_flag_compiles(-fstack-protector-strong CMAKE_C_FLAGS)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
add_if_flag_compiles(-Wa,--noexecstack CMAKE_C_FLAGS)
|
||||
add_if_flag_compiles(-no-canonical-prefixes CMAKE_C_FLAGS)
|
||||
add_definitions(-DANDROID -D__ANDROID_API__=21)
|
||||
include_directories(external/android/native_app_glue)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -uANativeActivity_onCreate")
|
||||
|
||||
find_library(OPENGL_LIBRARY OpenGL)
|
||||
set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
|
||||
|
||||
elseif(${PLATFORM} MATCHES "Raspberry Pi")
|
||||
set(PLATFORM_CPP "PLATFORM_RPI")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||
|
||||
add_definitions(-D_DEFAULT_SOURCE)
|
||||
|
||||
find_library(GLESV2 brcmGLESv2 HINTS /opt/vc/lib)
|
||||
find_library(EGL brcmEGL HINTS /opt/vc/lib)
|
||||
find_library(BCMHOST bcm_host HINTS /opt/vc/lib)
|
||||
include_directories(/opt/vc/include /opt/vc/include/interface/vmcs_host/linux /opt/vc/include/interface/vcos/pthreads)
|
||||
link_directories(/opt/vc/lib)
|
||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${BCMHOST} pthread rt m dl)
|
||||
|
||||
elseif(${PLATFORM} MATCHES "DRM")
|
||||
set(PLATFORM_CPP "PLATFORM_DRM")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||
|
||||
add_definitions(-D_DEFAULT_SOURCE)
|
||||
add_definitions(-DEGL_NO_X11)
|
||||
add_definitions(-DPLATFORM_DRM)
|
||||
|
||||
find_library(GLESV2 GLESv2)
|
||||
find_library(EGL EGL)
|
||||
find_library(DRM drm)
|
||||
find_library(GBM gbm)
|
||||
|
||||
include_directories(/usr/include/libdrm)
|
||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} pthread m dl)
|
||||
|
||||
endif()
|
||||
|
||||
if (${OPENGL_VERSION})
|
||||
set(${SUGGESTED_GRAPHICS} "${GRAPHICS}")
|
||||
if (${OPENGL_VERSION} MATCHES "3.3")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
|
||||
elseif (${OPENGL_VERSION} MATCHES "2.1")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_21")
|
||||
elseif (${OPENGL_VERSION} MATCHES "1.1")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_11")
|
||||
elseif (${OPENGL_VERSION} MATCHES "ES 2.0")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||
endif()
|
||||
if ("${SUGGESTED_GRAPHICS}" AND NOT "${SUGGESTED_GRAPHICS}" STREQUAL "${GRAPHICS}")
|
||||
message(WARNING "You are overriding the suggested GRAPHICS=${SUGGESTED_GRAPHICS} with ${GRAPHICS}! This may fail")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT GRAPHICS)
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
|
||||
endif()
|
||||
|
||||
include_directories(${OPENGL_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR})
|
||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY})
|
||||
include(LibraryPathToLinkerFlags)
|
||||
library_path_to_linker_flags(__PKG_CONFIG_LIBS_PRIVATE "${LIBS_PRIVATE}")
|
||||
|
||||
if(STATIC)
|
||||
MESSAGE(STATUS "Building raylib static library")
|
||||
if(${PLATFORM} MATCHES "Web")
|
||||
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
|
||||
endif()
|
||||
|
||||
add_library(raylib_static STATIC ${sources})
|
||||
|
||||
target_compile_definitions(raylib_static
|
||||
PUBLIC ${PLATFORM_CPP}
|
||||
PUBLIC PLATFORM=${PLATFORM_CPP}
|
||||
PUBLIC ${GRAPHICS}
|
||||
PUBLIC GRAPHICS=${GRAPHICS}
|
||||
)
|
||||
|
||||
target_link_libraries(raylib_static
|
||||
PUBLIC ${LIBS_PRIVATE}
|
||||
)
|
||||
|
||||
set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${GLFW_PKG_LIBS})
|
||||
string (REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
|
||||
if (${PLATFORM} MATCHES "Desktop")
|
||||
target_link_libraries(raylib_static PRIVATE glfw ${GLFW_LIBRARIES} ${LIBS_PRIVATE})
|
||||
endif()
|
||||
|
||||
if (WITH_PIC)
|
||||
set_property(TARGET raylib_static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
set_target_properties(raylib_static PROPERTIES PUBLIC_HEADER "raylib.h")
|
||||
if(NOT MSVC) # Keep lib*.(a|dll) name, but avoid *.lib files overwriting each other on Windows
|
||||
set_target_properties(raylib_static PROPERTIES OUTPUT_NAME raylib)
|
||||
endif()
|
||||
install(
|
||||
TARGETS raylib_static
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
set_target_properties(raylib_static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
add_test("pkg-config--static" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh --static)
|
||||
endif(STATIC)
|
||||
if (STATIC)
|
||||
MESSAGE(STATUS "Building raylib static library")
|
||||
|
||||
add_library(raylib STATIC ${raylib_sources} ${raylib_public_headers})
|
||||
add_library(raylib_static ALIAS raylib)
|
||||
|
||||
add_test("pkg-config--static" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh --static)
|
||||
endif (STATIC)
|
||||
|
||||
|
||||
if(SHARED)
|
||||
MESSAGE(STATUS "Building raylib shared library")
|
||||
add_library(raylib SHARED ${sources})
|
||||
if (SHARED)
|
||||
MESSAGE(STATUS "Building raylib shared library")
|
||||
add_library(raylib SHARED ${raylib_sources} ${raylib_public_headers})
|
||||
|
||||
if (MSVC)
|
||||
target_compile_definitions(raylib
|
||||
PRIVATE $<BUILD_INTERFACE:BUILD_LIBTYPE_SHARED>
|
||||
INTERFACE $<INSTALL_INTERFACE:USE_LIBTYPE_SHARED>
|
||||
)
|
||||
endif ()
|
||||
|
||||
add_test("pkg-config" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh)
|
||||
endif ()
|
||||
|
||||
target_compile_definitions(raylib
|
||||
PUBLIC ${PLATFORM_CPP}
|
||||
PUBLIC ${GRAPHICS}
|
||||
)
|
||||
# Setting target properties
|
||||
set_target_properties(raylib PROPERTIES
|
||||
PUBLIC_HEADER "${raylib_public_headers}"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${API_VERSION}
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_definitions(raylib
|
||||
PRIVATE $<BUILD_INTERFACE:BUILD_LIBTYPE_SHARED>
|
||||
INTERFACE $<INSTALL_INTERFACE:USE_LIBTYPE_SHARED>
|
||||
)
|
||||
endif()
|
||||
if (WITH_PIC OR SHARED)
|
||||
set_property(TARGET raylib PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif ()
|
||||
|
||||
set(PKG_CONFIG_LIBS_EXTRA "")
|
||||
|
||||
set_property(TARGET raylib PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
|
||||
target_link_libraries(raylib ${LIBS_PRIVATE})
|
||||
if (${PLATFORM} MATCHES "Desktop")
|
||||
# Linking libraries
|
||||
target_link_libraries(raylib "${LIBS_PRIVATE}")
|
||||
if (${PLATFORM} MATCHES "Desktop")
|
||||
target_link_libraries(raylib glfw)
|
||||
endif()
|
||||
set_target_properties(raylib PROPERTIES
|
||||
PUBLIC_HEADER "raylib.h"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${API_VERSION}
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
install(
|
||||
TARGETS raylib
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
PUBLIC_HEADER DESTINATION "include"
|
||||
)
|
||||
else()
|
||||
install(
|
||||
TARGETS raylib
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
endif()
|
||||
set_target_properties(raylib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
# Adding compile definitions
|
||||
target_compile_definitions(raylib
|
||||
PUBLIC "${PLATFORM_CPP}"
|
||||
PUBLIC "${GRAPHICS}"
|
||||
)
|
||||
|
||||
add_test("pkg-config" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh)
|
||||
else(SHARED)
|
||||
add_library(raylib ALIAS raylib_static)
|
||||
endif(SHARED)
|
||||
# Registering include directories
|
||||
target_include_directories(raylib
|
||||
PUBLIC
|
||||
$<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external
|
||||
${CMAKE_BINARY_DIR} # For cmake/config.h
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
${OPENAL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if (NOT DEFINED PKG_CONFIG_LIBS_EXTRA)
|
||||
set(PKG_CONFIG_LIBS_EXTRA "${PKG_CONFIG_LIBS_PRIVATE}")
|
||||
endif()
|
||||
# Copy the header files to the build directory for convenience
|
||||
file(COPY ${raylib_public_headers} DESTINATION "include")
|
||||
|
||||
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
||||
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
configure_file(../raylib.pc.in raylib.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
configure_file(../cmake/raylib-config-version.cmake raylib-config-version.cmake @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/../cmake/raylib-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
|
||||
|
||||
# populates raylib_{FOUND, INCLUDE_DIRS, LIBRARIES, LDFLAGS, DEFINITIONS}
|
||||
include(PopulateConfigVariablesLocally)
|
||||
populate_config_variables_locally(raylib)
|
||||
|
||||
# Copy the header files to the build directory
|
||||
file(COPY "raylib.h" DESTINATION ".")
|
||||
file(COPY "rlgl.h" DESTINATION ".")
|
||||
file(COPY "physac.h" DESTINATION ".")
|
||||
file(COPY "raymath.h" DESTINATION ".")
|
||||
file(COPY "raudio.h" DESTINATION ".")
|
||||
|
||||
# Also install them
|
||||
install(FILES "raylib.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(FILES "rlgl.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(FILES "physac.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(FILES "raymath.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(FILES "raudio.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
include(InstallConfigurations)
|
||||
|
||||
# Print the flags for the user
|
||||
if (DEFINED CMAKE_BUILD_TYPE)
|
||||
message(STATUS "Generated build type: ${CMAKE_BUILD_TYPE}")
|
||||
else()
|
||||
message(STATUS "Generated config types: ${CMAKE_CONFIGURATION_TYPES}")
|
||||
endif()
|
||||
message(STATUS "Generated build type: ${CMAKE_BUILD_TYPE}")
|
||||
else ()
|
||||
message(STATUS "Generated config types: ${CMAKE_CONFIGURATION_TYPES}")
|
||||
endif ()
|
||||
|
||||
message(STATUS "Compiling with the flags:")
|
||||
message(STATUS " PLATFORM=" ${PLATFORM_CPP})
|
||||
message(STATUS " GRAPHICS=" ${GRAPHICS})
|
||||
|
||||
# Packaging
|
||||
SET(CPACK_PACKAGE_NAME "raylib")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simple and easy-to-use library to enjoy videogames programming")
|
||||
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/../README.md")
|
||||
SET(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/../README.md")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "raylib-${PROJECT_VERSION}$ENV{RAYLIB_PACKAGE_SUFFIX}")
|
||||
SET(CPACK_GENERATOR "ZIP;TGZ") # Remove this, if you want the NSIS installer on Windows
|
||||
include(CPack)
|
||||
include(PackConfigurations)
|
||||
|
||||
enable_testing()
|
||||
|
||||
@ -1,115 +0,0 @@
|
||||
### Config options ###
|
||||
include(CMakeDependentOption)
|
||||
include(EnumOption)
|
||||
|
||||
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM" "Platform to build for.")
|
||||
|
||||
enum_option(OPENGL_VERSION "OFF;3.3;2.1;1.1;ES 2.0" "Force a specific OpenGL Version?")
|
||||
|
||||
# Shared library is always PIC. Static library should be PIC too if linked into a shared library
|
||||
option(WITH_PIC "Compile static library as position-independent code" OFF)
|
||||
option(SHARED "Build raylib as a dynamic library" OFF)
|
||||
option(STATIC "Build raylib as a static library" ON)
|
||||
option(MACOS_FATLIB "Build fat library for both i386 and x86_64 on macOS" OFF)
|
||||
option(USE_AUDIO "Build raylib with audio module" ON)
|
||||
|
||||
enum_option(USE_EXTERNAL_GLFW "OFF;IF_POSSIBLE;ON" "Link raylib against system GLFW instead of embedded one")
|
||||
if(UNIX AND NOT APPLE)
|
||||
option(USE_WAYLAND "Use Wayland for window creation" OFF)
|
||||
endif()
|
||||
|
||||
option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF)
|
||||
set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option")
|
||||
|
||||
# core.c
|
||||
option(SUPPORT_CAMERA_SYSTEM "Provide camera module (camera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON)
|
||||
option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag" ON)
|
||||
option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON)
|
||||
option(SUPPORT_SSH_KEYBOARD_RPI "Reconfigure standard input to receive key inputs, works with SSH connection" OFF)
|
||||
option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON)
|
||||
option(SUPPORT_SCREEN_CAPTURE "Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()" ON)
|
||||
option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()" ON)
|
||||
option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" OFF)
|
||||
option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF)
|
||||
option(SUPPORT_HIGH_DPI "Support high DPI displays" OFF)
|
||||
option(SUPPORT_DATA_STORAGE "Support for persistent data storage" ON)
|
||||
|
||||
# rlgl.h
|
||||
option(SUPPORT_VR_SIMULATOR "Support VR simulation functionality (stereo rendering)" ON)
|
||||
|
||||
# shapes.c
|
||||
option(SUPPORT_FONT_TEXTURE "Draw rectangle shapes using font texture white character instead of default white texture. Allows drawing rectangles and text with a single draw call, very useful for GUI systems!" ON)
|
||||
option(SUPPORT_QUADS_DRAW_MODE "Use QUADS instead of TRIANGLES for drawing when possible. Some lines-based shapes could still use lines" ON)
|
||||
|
||||
# textures.c
|
||||
option(SUPPORT_IMAGE_EXPORT "Support image exporting to file" ON)
|
||||
option(SUPPORT_IMAGE_GENERATION "Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)" ON)
|
||||
option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()" ON)
|
||||
option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON)
|
||||
option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON)
|
||||
option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON)
|
||||
option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ON)
|
||||
option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ON)
|
||||
option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" ${OFF})
|
||||
option(SUPPORT_FILEFORMAT_TGA "Support loading TGA as textures" ${OFF})
|
||||
option(SUPPORT_FILEFORMAT_JPG "Support loading JPG as textures" ${OFF})
|
||||
option(SUPPORT_FILEFORMAT_GIF "Support loading GIF as textures" ${OFF})
|
||||
option(SUPPORT_FILEFORMAT_PSD "Support loading PSD as textures" ${OFF})
|
||||
option(SUPPORT_FILEFORMAT_PKM "Support loading PKM as textures" ${OFF})
|
||||
option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures" ${OFF})
|
||||
|
||||
# text.c
|
||||
option(SUPPORT_FILEFORMAT_FNT "Support loading fonts in FNT format" ON)
|
||||
option(SUPPORT_FILEFORMAT_TTF "Support loading font in TTF/OTF format" ON)
|
||||
option(SUPPORT_TEXT_MANIPULATION "Support text manipulation functions" ON)
|
||||
|
||||
# models.c
|
||||
option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON)
|
||||
option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON)
|
||||
option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format" ON)
|
||||
option(SUPPORT_FILEFORMAT_IQM "Support loading IQM file format" ON)
|
||||
option(SUPPORT_FILEFORMAT_GLTF "Support loading GLTF file format" ON)
|
||||
|
||||
# raudio.c
|
||||
option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON)
|
||||
option(SUPPORT_FILEFORMAT_OGG "Support loading OGG for sound" ON)
|
||||
option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON)
|
||||
option(SUPPORT_FILEFORMAT_MOD "Support loading MOD for sound" ON)
|
||||
option(SUPPORT_FILEFORMAT_MP3 "Support loading MP3 for sound" ON)
|
||||
option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF})
|
||||
|
||||
# utils.c
|
||||
option(SUPPORT_TRACELOG "Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown" ON)
|
||||
|
||||
if(NOT (STATIC OR SHARED))
|
||||
message(FATAL_ERROR "Nothing to do if both -DSHARED=OFF and -DSTATIC=OFF...")
|
||||
endif()
|
||||
|
||||
if (DEFINED BUILD_SHARED_LIBS)
|
||||
set(SHARED ${BUILD_SHARED_LIBS})
|
||||
if (${BUILD_SHARED_LIBS})
|
||||
set(STATIC OFF)
|
||||
else()
|
||||
set(STATIC ON)
|
||||
endif()
|
||||
endif()
|
||||
if(DEFINED SHARED_RAYLIB)
|
||||
set(SHARED ${SHARED_RAYLIB})
|
||||
message(DEPRECATION "-DSHARED_RAYLIB is deprecated. Please use -DSHARED instead.")
|
||||
endif()
|
||||
if(DEFINED STATIC_RAYLIB)
|
||||
set(STATIC ${STATIC_RAYLIB})
|
||||
message(DEPRECATION "-DSTATIC_RAYLIB is deprecated. Please use -DSTATIC instead.")
|
||||
endif()
|
||||
|
||||
if(${PLATFORM} MATCHES "Desktop" AND APPLE)
|
||||
if(MACOS_FATLIB)
|
||||
if (CMAKE_OSX_ARCHITECTURES)
|
||||
message(FATAL_ERROR "User supplied -DCMAKE_OSX_ARCHITECTURES overrides -DMACOS_FATLIB=ON")
|
||||
else()
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# vim: ft=cmake
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
// Edit to control what features Makefile'd raylib is compiled with
|
||||
#if defined(RAYLIB_CMAKE)
|
||||
// Edit CMakeOptions.txt for CMake instead
|
||||
// Edit cmake/RaylibOptions.cmake for CMake instead
|
||||
#include "cmake/config.h"
|
||||
#else
|
||||
|
||||
|
||||
Reference in New Issue
Block a user