github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/tests/raylib/CMakeLists.txt (about) 1 # Setup the project and settings 2 project(raylib C) 3 set(PROJECT_VERSION 4.2.0) 4 set(API_VERSION 420) 5 6 include(GNUInstallDirs) 7 include(JoinPaths) 8 9 # Sets build type if not set by now 10 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 11 if(RAYLIB_IS_MAIN) 12 set(default_build_type Debug) 13 else() 14 message(WARNING "Default build type is not set (CMAKE_BUILD_TYPE)") 15 endif() 16 17 message(STATUS "Setting build type to '${default_build_type}' as none was specified.") 18 19 set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) 20 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") 21 endif() 22 23 # Used as public API to be included into other projects 24 set(raylib_public_headers 25 raylib.h 26 rlgl.h 27 raymath.h 28 ) 29 30 # Sources to be compiled 31 set(raylib_sources 32 rcore.c 33 rmodels.c 34 rshapes.c 35 rtext.c 36 rtextures.c 37 utils.c 38 ) 39 40 # <root>/cmake/GlfwImport.cmake handles the details around the inclusion of glfw 41 include(GlfwImport) 42 43 # Sets additional platform options and link libraries for each platform 44 # also selects the proper graphics API and version for that platform 45 # Produces a variable LIBS_PRIVATE that will be used later 46 include(LibraryConfigurations) 47 48 if (USE_AUDIO) 49 MESSAGE(STATUS "Audio Backend: miniaudio") 50 list(APPEND raylib_sources raudio.c) 51 else () 52 MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)") 53 endif () 54 55 56 add_library(raylib ${raylib_sources} ${raylib_public_headers}) 57 58 if (NOT BUILD_SHARED_LIBS) 59 MESSAGE(STATUS "Building raylib static library") 60 add_library(raylib_static ALIAS raylib) 61 else() 62 MESSAGE(STATUS "Building raylib shared library") 63 if (MSVC) 64 target_compile_definitions(raylib 65 PRIVATE $<BUILD_INTERFACE:BUILD_LIBTYPE_SHARED> 66 INTERFACE $<INSTALL_INTERFACE:USE_LIBTYPE_SHARED> 67 ) 68 endif () 69 endif() 70 71 set_target_properties(raylib PROPERTIES 72 PUBLIC_HEADER "${raylib_public_headers}" 73 VERSION ${PROJECT_VERSION} 74 SOVERSION ${API_VERSION} 75 ) 76 77 if (WITH_PIC OR BUILD_SHARED_LIBS) 78 set_property(TARGET raylib PROPERTY POSITION_INDEPENDENT_CODE ON) 79 endif () 80 81 target_link_libraries(raylib "${LIBS_PRIVATE}") 82 83 # Sets some compile time definitions for the pre-processor 84 # If CUSTOMIZE_BUILD option is on you will not use config.h by default 85 # and you will be able to select more build options 86 include(CompileDefinitions) 87 88 # Registering include directories 89 target_include_directories(raylib 90 PUBLIC 91 $<INSTALL_INTERFACE:include> 92 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> 93 PRIVATE 94 ${CMAKE_CURRENT_SOURCE_DIR} 95 ${OPENGL_INCLUDE_DIR} 96 ${OPENAL_INCLUDE_DIR} 97 ) 98 99 # Copy the header files to the build directory for convenience 100 file(COPY ${raylib_public_headers} DESTINATION "include") 101 102 # Includes information on how the library will be installed on the system 103 # when cmake --install is run 104 include(InstallConfigurations) 105 106 # Print the flags for the user 107 if (DEFINED CMAKE_BUILD_TYPE) 108 message(STATUS "Generated build type: ${CMAKE_BUILD_TYPE}") 109 else () 110 message(STATUS "Generated config types: ${CMAKE_CONFIGURATION_TYPES}") 111 endif () 112 113 message(STATUS "Compiling with the flags:") 114 message(STATUS " PLATFORM=" ${PLATFORM_CPP}) 115 message(STATUS " GRAPHICS=" ${GRAPHICS}) 116 117 # Options if you want to create an installer using CPack 118 include(PackConfigurations) 119 120 enable_testing()