|
@@ -1,5 +1,5 @@
|
|
# Setup the project and settings
|
|
# Setup the project and settings
|
|
-project(raylib)
|
|
|
|
|
|
+project(raylib C)
|
|
include(GNUInstallDirs)
|
|
include(GNUInstallDirs)
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
|
|
|
|
|
@@ -13,14 +13,6 @@ configure_file(config.h.in ${CMAKE_BINARY_DIR}/cmake/config.h)
|
|
include_directories(${CMAKE_BINARY_DIR})
|
|
include_directories(${CMAKE_BINARY_DIR})
|
|
include_directories(SYSTEM .)
|
|
include_directories(SYSTEM .)
|
|
|
|
|
|
-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()
|
|
|
|
-
|
|
|
|
# Get the sources together
|
|
# Get the sources together
|
|
file(GLOB raylib_sources *.c)
|
|
file(GLOB raylib_sources *.c)
|
|
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/rglfw.c)
|
|
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/rglfw.c)
|
|
@@ -72,9 +64,9 @@ if(${PLATFORM} MATCHES "Desktop")
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
endif()
|
|
endif()
|
|
|
|
|
|
- # Need to force OpenGL 3.3 on OS X
|
|
|
|
- # See: https://github.com/raysan5/raylib/issues/341
|
|
|
|
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")
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
|
|
link_libraries("${LIBS_PRIVATE}")
|
|
link_libraries("${LIBS_PRIVATE}")
|
|
elseif(WIN32)
|
|
elseif(WIN32)
|
|
@@ -85,12 +77,9 @@ elseif(${PLATFORM} MATCHES "Web")
|
|
set(PLATFORM "PLATFORM_WEB")
|
|
set(PLATFORM "PLATFORM_WEB")
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
|
|
|
|
- # Need to use `emcc`
|
|
|
|
- set(CMAKE_C_COMPILER "emcc")
|
|
|
|
- set(CMAKE_CXX_COMPILER "em++")
|
|
|
|
|
|
+ set(CMAKE_C_FLAGS "-s USE_GLFW=3 -s ASSERTIONS=1 --profiling")
|
|
|
|
|
|
# Change the name of the output library
|
|
# Change the name of the output library
|
|
- set(RAYLIB "libraylib.bc")
|
|
|
|
|
|
|
|
elseif(${PLATFORM} MATCHES "Android")
|
|
elseif(${PLATFORM} MATCHES "Android")
|
|
set(PLATFORM "PLATFORM_ANDROID")
|
|
set(PLATFORM "PLATFORM_ANDROID")
|
|
@@ -110,89 +99,87 @@ elseif(${PLATFORM} MATCHES "Raspberry Pi")
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
endif()
|
|
endif()
|
|
|
|
|
|
-# Which platform?
|
|
|
|
-if(${PLATFORM} MATCHES "PLATFORM_WEB")
|
|
|
|
- # For the web.
|
|
|
|
- add_executable(${RAYLIB} ${sources})
|
|
|
|
|
|
+if(${SHARED})
|
|
|
|
+ add_library(${RAYLIB}_shared SHARED ${sources})
|
|
|
|
|
|
-else()
|
|
|
|
- if(${SHARED})
|
|
|
|
- add_library(${RAYLIB}_shared SHARED ${sources})
|
|
|
|
|
|
+ target_compile_definitions(${RAYLIB}_shared
|
|
|
|
+ PUBLIC ${PLATFORM}
|
|
|
|
+ PUBLIC ${GRAPHICS}
|
|
|
|
+ )
|
|
|
|
|
|
- target_compile_definitions(${RAYLIB}_shared
|
|
|
|
- PUBLIC ${PLATFORM}
|
|
|
|
- PUBLIC ${GRAPHICS}
|
|
|
|
- )
|
|
|
|
|
|
+ set_property(TARGET ${RAYLIB}_shared 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)
|
|
|
|
|
|
- set_property(TARGET ${RAYLIB}_shared 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}_shared ${LIBS_PRIVATE})
|
|
|
|
- if (${PLATFORM} MATCHES "Desktop")
|
|
|
|
- target_link_libraries(${RAYLIB}_shared glfw ${GLFW_LIBRARIES})
|
|
|
|
- endif()
|
|
|
|
- if (UNIX AND ${FILESYSTEM_LACKS_SYMLINKS})
|
|
|
|
- MESSAGE(WARNING "Can't version UNIX shared library on file system without symlink support")
|
|
|
|
- else()
|
|
|
|
- set_target_properties(${RAYLIB}_shared PROPERTIES
|
|
|
|
- VERSION ${PROJECT_VERSION}
|
|
|
|
- SOVERSION ${API_VERSION}
|
|
|
|
- )
|
|
|
|
- endif()
|
|
|
|
- set_target_properties(${RAYLIB}_shared PROPERTIES
|
|
|
|
- PUBLIC_HEADER "raylib.h"
|
|
|
|
- )
|
|
|
|
- if(WIN32)
|
|
|
|
- install(
|
|
|
|
- TARGETS ${RAYLIB}_shared
|
|
|
|
- RUNTIME DESTINATION lib
|
|
|
|
- PUBLIC_HEADER DESTINATION include
|
|
|
|
- )
|
|
|
|
- else() # Keep lib*.(a|dll) name, but avoid *.lib files overwriting each other on Windows
|
|
|
|
- set_target_properties(${RAYLIB}_shared PROPERTIES OUTPUT_NAME ${RAYLIB})
|
|
|
|
- install(
|
|
|
|
- TARGETS ${RAYLIB}_shared
|
|
|
|
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
|
|
+ target_link_libraries(${RAYLIB}_shared ${LIBS_PRIVATE})
|
|
|
|
+ if (${PLATFORM} MATCHES "Desktop")
|
|
|
|
+ target_link_libraries(${RAYLIB}_shared glfw ${GLFW_LIBRARIES})
|
|
|
|
+ endif()
|
|
|
|
+ if (UNIX AND ${FILESYSTEM_LACKS_SYMLINKS})
|
|
|
|
+ MESSAGE(WARNING "Can't version UNIX shared library on file system without symlink support")
|
|
|
|
+ else()
|
|
|
|
+ set_target_properties(${RAYLIB}_shared PROPERTIES
|
|
|
|
+ VERSION ${PROJECT_VERSION}
|
|
|
|
+ SOVERSION ${API_VERSION}
|
|
)
|
|
)
|
|
- endif()
|
|
|
|
- endif(${SHARED})
|
|
|
|
-
|
|
|
|
- if(${STATIC})
|
|
|
|
- add_library(${RAYLIB} STATIC ${sources})
|
|
|
|
-
|
|
|
|
- target_compile_definitions(${RAYLIB}
|
|
|
|
- PUBLIC ${PLATFORM}
|
|
|
|
- PUBLIC ${GRAPHICS}
|
|
|
|
|
|
+ endif()
|
|
|
|
+ set_target_properties(${RAYLIB}_shared PROPERTIES
|
|
|
|
+ PUBLIC_HEADER "raylib.h"
|
|
|
|
+ )
|
|
|
|
+ if(WIN32)
|
|
|
|
+ install(
|
|
|
|
+ TARGETS ${RAYLIB}_shared
|
|
|
|
+ RUNTIME DESTINATION lib
|
|
|
|
+ PUBLIC_HEADER DESTINATION include
|
|
)
|
|
)
|
|
-
|
|
|
|
- set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE})
|
|
|
|
- if (${PLATFORM} MATCHES "Desktop")
|
|
|
|
- target_link_libraries(${RAYLIB} glfw ${GLFW_LIBRARIES})
|
|
|
|
- endif()
|
|
|
|
-
|
|
|
|
- if (WITH_PIC)
|
|
|
|
- set_property(TARGET ${RAYLIB} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
|
|
- endif()
|
|
|
|
- set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h")
|
|
|
|
- install(TARGETS ${RAYLIB}
|
|
|
|
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
|
|
+ else() # Keep lib*.(a|dll) name, but avoid *.lib files overwriting each other on Windows
|
|
|
|
+ set_target_properties(${RAYLIB}_shared PROPERTIES OUTPUT_NAME ${RAYLIB})
|
|
|
|
+ install(
|
|
|
|
+ TARGETS ${RAYLIB}_shared
|
|
|
|
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
)
|
|
)
|
|
- endif(${STATIC})
|
|
|
|
|
|
+ endif()
|
|
|
|
+endif(${SHARED})
|
|
|
|
|
|
- configure_file(../raylib.pc.in raylib.pc @ONLY)
|
|
|
|
- install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
|
|
|
|
+if(${STATIC})
|
|
|
|
+ if(${PLATFORM} MATCHES "PLATFORM_WEB")
|
|
|
|
+ set(CMAKE_STATIC_LIBRARY_SUFFIX ".bc")
|
|
|
|
+ endif()
|
|
|
|
+
|
|
|
|
+ add_library(${RAYLIB} STATIC ${sources})
|
|
|
|
+
|
|
|
|
+ set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE})
|
|
|
|
+ if (${PLATFORM} MATCHES "Desktop")
|
|
|
|
+ target_link_libraries(${RAYLIB} glfw ${GLFW_LIBRARIES})
|
|
|
|
+ endif()
|
|
|
|
+
|
|
|
|
+ if (WITH_PIC)
|
|
|
|
+ set_property(TARGET ${RAYLIB} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
|
|
+ endif()
|
|
|
|
+ set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h")
|
|
|
|
+ install(TARGETS ${RAYLIB}
|
|
|
|
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
+ )
|
|
|
|
+endif(${STATIC})
|
|
|
|
+
|
|
|
|
+configure_file(../raylib.pc.in raylib.pc @ONLY)
|
|
|
|
+install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
|
|
+
|
|
|
|
+# 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 "audio.h" DESTINATION ".")
|
|
|
|
+
|
|
|
|
+target_compile_definitions(${RAYLIB}
|
|
|
|
+ PUBLIC ${PLATFORM}
|
|
|
|
+ PUBLIC ${GRAPHICS}
|
|
|
|
+)
|
|
|
|
|
|
- # 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 "audio.h" DESTINATION ".")
|
|
|
|
-endif()
|
|
|
|
|
|
|
|
# Print the flags for the user
|
|
# Print the flags for the user
|
|
message(STATUS "Compiling with the flags:")
|
|
message(STATUS "Compiling with the flags:")
|