github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/tests/raylib/external/glfw/CMakeLists.txt (about)

     1  cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR)
     2  
     3  project(GLFW VERSION 3.4.0 LANGUAGES C)
     4  
     5  set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
     6  
     7  if (POLICY CMP0054)
     8      cmake_policy(SET CMP0054 NEW)
     9  endif()
    10  
    11  if (POLICY CMP0069)
    12      cmake_policy(SET CMP0069 NEW)
    13  endif()
    14  
    15  if (POLICY CMP0077)
    16      cmake_policy(SET CMP0077 NEW)
    17  endif()
    18  
    19  set_property(GLOBAL PROPERTY USE_FOLDERS ON)
    20  
    21  if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
    22      set(GLFW_STANDALONE TRUE)
    23  endif()
    24  
    25  option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
    26  option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
    27  option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE})
    28  option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
    29  option(GLFW_INSTALL "Generate installation target" ON)
    30  
    31  include(GNUInstallDirs)
    32  include(CMakeDependentOption)
    33  
    34  if (GLFW_USE_OSMESA)
    35      message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint")
    36  endif()
    37  
    38  cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF)
    39  cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF)
    40  cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF)
    41  cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland"
    42      "${GLFW_USE_WAYLAND}" "UNIX;NOT APPLE" OFF)
    43  
    44  cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
    45                         "WIN32" OFF)
    46  cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
    47                         "MSVC" OFF)
    48  
    49  set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING
    50      "Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)")
    51  
    52  if (GLFW_LIBRARY_TYPE)
    53      if (GLFW_LIBRARY_TYPE STREQUAL "SHARED")
    54          set(GLFW_BUILD_SHARED_LIBRARY TRUE)
    55      else()
    56          set(GLFW_BUILD_SHARED_LIBRARY FALSE)
    57      endif()
    58  else()
    59      set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
    60  endif()
    61  
    62  list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
    63  
    64  find_package(Threads REQUIRED)
    65  
    66  if (GLFW_BUILD_DOCS)
    67      set(DOXYGEN_SKIP_DOT TRUE)
    68      find_package(Doxygen)
    69  endif()
    70  
    71  #--------------------------------------------------------------------
    72  # Report backend selection
    73  #--------------------------------------------------------------------
    74  if (GLFW_BUILD_WIN32)
    75      message(STATUS "Including Win32 support")
    76  endif()
    77  if (GLFW_BUILD_COCOA)
    78      message(STATUS "Including Cocoa support")
    79  endif()
    80  if (GLFW_BUILD_WAYLAND)
    81      message(STATUS "Including Wayland support")
    82  endif()
    83  if (GLFW_BUILD_X11)
    84      message(STATUS "Including X11 support")
    85  endif()
    86  
    87  #--------------------------------------------------------------------
    88  # Apply Microsoft C runtime library option
    89  # This is here because it also applies to tests and examples
    90  #--------------------------------------------------------------------
    91  if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
    92      if (CMAKE_VERSION VERSION_LESS 3.15)
    93          foreach (flag CMAKE_C_FLAGS
    94                        CMAKE_C_FLAGS_DEBUG
    95                        CMAKE_C_FLAGS_RELEASE
    96                        CMAKE_C_FLAGS_MINSIZEREL
    97                        CMAKE_C_FLAGS_RELWITHDEBINFO)
    98  
    99              if (flag MATCHES "/MD")
   100                  string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
   101              endif()
   102              if (flag MATCHES "/MDd")
   103                  string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
   104              endif()
   105  
   106          endforeach()
   107      else()
   108          set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
   109      endif()
   110  endif()
   111  
   112  #--------------------------------------------------------------------
   113  # Create generated files
   114  #--------------------------------------------------------------------
   115  include(CMakePackageConfigHelpers)
   116  
   117  set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/glfw3")
   118  
   119  configure_package_config_file(CMake/glfw3Config.cmake.in
   120                                src/glfw3Config.cmake
   121                                INSTALL_DESTINATION "${GLFW_CONFIG_PATH}"
   122                                NO_CHECK_REQUIRED_COMPONENTS_MACRO)
   123  
   124  write_basic_package_version_file(src/glfw3ConfigVersion.cmake
   125                                   VERSION ${GLFW_VERSION}
   126                                   COMPATIBILITY SameMajorVersion)
   127  
   128  #--------------------------------------------------------------------
   129  # Add subdirectories
   130  #--------------------------------------------------------------------
   131  add_subdirectory(src)
   132  
   133  if (GLFW_BUILD_EXAMPLES)
   134      add_subdirectory(examples)
   135  endif()
   136  
   137  if (GLFW_BUILD_TESTS)
   138      add_subdirectory(tests)
   139  endif()
   140  
   141  if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
   142      add_subdirectory(docs)
   143  endif()
   144  
   145  #--------------------------------------------------------------------
   146  # Install files other than the library
   147  # The library is installed by src/CMakeLists.txt
   148  #--------------------------------------------------------------------
   149  if (GLFW_INSTALL)
   150      install(DIRECTORY include/GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
   151              FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h)
   152  
   153      install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
   154                    "${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
   155              DESTINATION "${GLFW_CONFIG_PATH}")
   156  
   157      install(EXPORT glfwTargets FILE glfw3Targets.cmake
   158              EXPORT_LINK_INTERFACE_LIBRARIES
   159              DESTINATION "${GLFW_CONFIG_PATH}")
   160      install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
   161              DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
   162  
   163      if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
   164          install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html"
   165                  DESTINATION "${CMAKE_INSTALL_DOCDIR}")
   166      endif()
   167  
   168      # Only generate this target if no higher-level project already has
   169      if (NOT TARGET uninstall)
   170          configure_file(CMake/cmake_uninstall.cmake.in
   171                         cmake_uninstall.cmake IMMEDIATE @ONLY)
   172  
   173          add_custom_target(uninstall
   174                            "${CMAKE_COMMAND}" -P
   175                            "${GLFW_BINARY_DIR}/cmake_uninstall.cmake")
   176          set_target_properties(uninstall PROPERTIES FOLDER "GLFW3")
   177      endif()
   178  endif()
   179