diff options
| author | hristo <[email protected]> | 2021-01-26 15:34:27 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-01-26 14:34:27 +0100 |
| commit | 88a6f16c9a552ebb8c39fff57cf16cfce7c88913 (patch) | |
| tree | 01f43248128d37b0c2c2be628797197f30a3df60 /cmake/LibraryConfigurations.cmake | |
| parent | 65b299c6cfdfd85a79833641c96b41babd50c872 (diff) | |
| download | raylib-88a6f16c9a552ebb8c39fff57cf16cfce7c88913.tar.gz raylib-88a6f16c9a552ebb8c39fff57cf16cfce7c88913.zip | |
Documentation cmake (#1549)
* Documenting the compiler flags
* Moved some android compiler flags and added documentation on them too.
* Some more restructuring.
Removed unnecessary comments that were self described by the code.
Added some more explanations around certain parts of CMake and especially around compiler flags.
Diffstat (limited to 'cmake/LibraryConfigurations.cmake')
| -rw-r--r-- | cmake/LibraryConfigurations.cmake | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake index cf5e85f8..1b1961b9 100644 --- a/cmake/LibraryConfigurations.cmake +++ b/cmake/LibraryConfigurations.cmake @@ -1,7 +1,7 @@ -if(${PLATFORM} MATCHES "Desktop") +if (${PLATFORM} MATCHES "Desktop") set(PLATFORM_CPP "PLATFORM_DESKTOP") - if(APPLE) + 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") @@ -11,40 +11,35 @@ if(${PLATFORM} MATCHES "Desktop") 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) + endif () + elseif (WIN32) add_definitions(-D_CRT_SECURE_NO_WARNINGS) set(LIBS_PRIVATE ${LIBS_PRIVATE} winmm) - else() + else () find_library(pthread NAMES pthread) find_package(OpenGL QUIET) if ("${OPENGL_LIBRARIES}" STREQUAL "") set(OPENGL_LIBRARIES "GL") - endif() + endif () if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD") find_library(OSS_LIBRARY ossaudio) - endif() + endif () set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY}) - endif() + endif () -elseif(${PLATFORM} MATCHES "Web") +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") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 --profiling") set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") -elseif(${PLATFORM} MATCHES "Android") +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") @@ -52,7 +47,7 @@ elseif(${PLATFORM} MATCHES "Android") find_library(OPENGL_LIBRARY OpenGL) set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c) -elseif(${PLATFORM} MATCHES "Raspberry Pi") +elseif (${PLATFORM} MATCHES "Raspberry Pi") set(PLATFORM_CPP "PLATFORM_RPI") set(GRAPHICS "GRAPHICS_API_OPENGL_ES2") @@ -65,7 +60,7 @@ elseif(${PLATFORM} MATCHES "Raspberry Pi") link_directories(/opt/vc/lib) set(LIBS_PRIVATE ${GLESV2} ${EGL} ${BCMHOST} pthread rt m dl) -elseif(${PLATFORM} MATCHES "DRM") +elseif (${PLATFORM} MATCHES "DRM") set(PLATFORM_CPP "PLATFORM_DRM") set(GRAPHICS "GRAPHICS_API_OPENGL_ES2") @@ -81,7 +76,7 @@ elseif(${PLATFORM} MATCHES "DRM") include_directories(/usr/include/libdrm) set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} pthread m dl) -endif() +endif () if (${OPENGL_VERSION}) set(${SUGGESTED_GRAPHICS} "${GRAPHICS}") @@ -93,12 +88,18 @@ if (${OPENGL_VERSION}) set(GRAPHICS "GRAPHICS_API_OPENGL_11") elseif (${OPENGL_VERSION} MATCHES "ES 2.0") set(GRAPHICS "GRAPHICS_API_OPENGL_ES2") - endif() + 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() + endif () +endif () -if(NOT GRAPHICS) +if (NOT GRAPHICS) set(GRAPHICS "GRAPHICS_API_OPENGL_33") -endif()
\ No newline at end of file +endif () + +set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY}) + +if (${PLATFORM} MATCHES "Desktop") + set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw) +endif ()
\ No newline at end of file |
