From f3210724809deded7c6d562075ff9b1b5456e9fa Mon Sep 17 00:00:00 2001 From: pradeep Date: Wed, 12 Feb 2020 21:55:16 +0530 Subject: [PATCH 1/2] Refactor CMakeLists.txt per recommended guidelines * Set default symbol visibility to hidden --- CMakeLists.txt | 16 +-- CMakeModules/ForgeBuildType.cmake | 10 +- ...stallDirs.cmake => ForgeInstallDirs.cmake} | 0 CMakeModules/GLSLtoH.cmake | 5 +- CMakeModules/HunterGate.cmake | 5 +- examples/CMakeModules/build_cl2hpp.cmake | 2 +- extern/glad/CMakeLists.txt | 8 +- src/api/c/CMakeLists.txt | 22 +-- src/api/cpp/CMakeLists.txt | 26 ++-- src/backend/CMakeLists.txt | 125 +++++++++--------- src/backend/common/CMakeLists.txt | 34 ++--- src/backend/glsl_shaders/CMakeLists.txt | 4 +- src/backend/opengl/CMakeLists.txt | 82 ++++++------ src/backend/opengl/glfw/CMakeLists.txt | 15 +-- src/backend/opengl/sdl/CMakeLists.txt | 15 +-- src/backend/opengl/window_impl.hpp | 7 +- 16 files changed, 195 insertions(+), 181 deletions(-) rename CMakeModules/{FGInstallDirs.cmake => ForgeInstallDirs.cmake} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6018eae3..9deb7631 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,18 +4,16 @@ project(Forge VERSION 1.1.0 LANGUAGES C CXX) set_property(GLOBAL PROPERTY USE_FOLDERS ON) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMakeModules") +list(APPEND CMAKE_PREFIX_PATH "${Forge_BINARY_DIR}/cmake") include(ForgeBuildType) -include(ForgeVersion) -include(FGInstallDirs) +include(ForgeInstallDirs) include(ForgeInternalUtils) include(ForgePlatformSetup) +include(ForgeVersion) -set_policies( - TYPE NEW - POLICIES CMP0072 CMP0077) +set_policies(TYPE NEW POLICIES CMP0072 CMP0077) option(BUILD_SHARED_LIBS "Build shared/static library" ON) option(FG_ENABLE_HUNTER "Use Hunter cmake package handler" OFF) @@ -126,7 +124,7 @@ write_basic_package_version_file( set(INCLUDE_DIRS include) set(CMAKE_DIR ${FG_INSTALL_CMAKE_DIR}) configure_package_config_file( - "${PROJECT_SOURCE_DIR}/CMakeModules/ForgeConfig.cmake.in" + "${Forge_SOURCE_DIR}/CMakeModules/ForgeConfig.cmake.in" "cmake_install/ForgeConfig.cmake" INSTALL_DESTINATION "${FG_INSTALL_CMAKE_DIR}" PATH_VARS INCLUDE_DIRS CMAKE_DIR @@ -146,7 +144,7 @@ install(EXPORT ForgeTargets set(INCLUDE_DIRS "${Forge_SOURCE_DIR}/include" "${Forge_BINARY_DIR}/include") set(CMAKE_DIR "${Forge_BINARY_DIR}") configure_package_config_file( - "${PROJECT_SOURCE_DIR}/CMakeModules/ForgeConfig.cmake.in" + "${Forge_SOURCE_DIR}/CMakeModules/ForgeConfig.cmake.in" "ForgeConfig.cmake" INSTALL_DESTINATION "${Forge_BINARY_DIR}" PATH_VARS INCLUDE_DIRS CMAKE_DIR diff --git a/CMakeModules/ForgeBuildType.cmake b/CMakeModules/ForgeBuildType.cmake index a444d816..27359896 100644 --- a/CMakeModules/ForgeBuildType.cmake +++ b/CMakeModules/ForgeBuildType.cmake @@ -3,21 +3,21 @@ # CMAKE_CONFIGURATION_TYPES variable indicated multi-config, but developers # might modify. if(NOT CMAKE_VERSION VERSION_LESS 3.9) - get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) elseif(CMAKE_CONFIGURATION_TYPES) # CMAKE_CONFIGURATION_TYPES is set by project() call - set(_isMultiConfig True) + set(isMultiConfig True) else() - set(_isMultiConfig False) + set(isMultiConfig False) endif() -if(_isMultiConfig) +if(isMultiConfig) set(CMAKE_CONFIGURATION_TYPES "Debug;MinSizeRel;Release;RelWithDebInfo" CACHE STRING "Configurations for Multi-Config CMake Generator" FORCE) else() set(default_build_type "Release") - if(EXISTS "${CMAKE_SOURCE_DIR}/.git") + if(EXISTS "${Forge_SOURCE_DIR}/.git") set(default_build_type "Debug") endif() if(NOT CMAKE_BUILD_TYPE) diff --git a/CMakeModules/FGInstallDirs.cmake b/CMakeModules/ForgeInstallDirs.cmake similarity index 100% rename from CMakeModules/FGInstallDirs.cmake rename to CMakeModules/ForgeInstallDirs.cmake diff --git a/CMakeModules/GLSLtoH.cmake b/CMakeModules/GLSLtoH.cmake index 3a7dd7d2..ac386c5a 100644 --- a/CMakeModules/GLSLtoH.cmake +++ b/CMakeModules/GLSLtoH.cmake @@ -23,12 +23,11 @@ # # where ns is the contents of kernel.cl.namespace. -include(CMakeParseArguments) - set(GLSL2CPP_PROGRAM "glsl2cpp") macro(convert_glsl_shaders_to_headers) - CMAKE_PARSE_ARGUMENTS(RTCS "" "VARNAME;EXTENSION;OUTPUT_DIR;TARGETS;NAMESPACE;EOF" "SOURCES" ${ARGN}) + cmake_parse_arguments( + RTCS "" "VARNAME;EXTENSION;OUTPUT_DIR;TARGETS;NAMESPACE;EOF" "SOURCES" ${ARGN}) set(_output_files "") foreach(_input_file ${RTCS_SOURCES}) diff --git a/CMakeModules/HunterGate.cmake b/CMakeModules/HunterGate.cmake index 99882d24..27094874 100644 --- a/CMakeModules/HunterGate.cmake +++ b/CMakeModules/HunterGate.cmake @@ -43,7 +43,10 @@ # * https://github.com/ruslo/hunter cmake_minimum_required(VERSION 3.0) # Minimum for Hunter -include(CMakeParseArguments) # cmake_parse_arguments + +# min cmake required for forge is 3.5, hence +# no need to include the below module to use cmake_parse_arguments +# include(CMakeParseArguments) option(HUNTER_ENABLED "Enable Hunter package manager support" ON) option(HUNTER_STATUS_PRINT "Print working status" ON) diff --git a/examples/CMakeModules/build_cl2hpp.cmake b/examples/CMakeModules/build_cl2hpp.cmake index a8d7ebcd..c8e50501 100644 --- a/examples/CMakeModules/build_cl2hpp.cmake +++ b/examples/CMakeModules/build_cl2hpp.cmake @@ -6,7 +6,7 @@ if (OpenCL_FOUND) "https://github.com/KhronosGroup/OpenCL-CLHPP/releases/download/v2.0.10/cl2.hpp") file(DOWNLOAD ${file_url} ${cl2hpp_header} EXPECTED_HASH MD5=c38d1b78cd98cc809fa2a49dbd1734a5 - SHOW_PROGRESS STATUS download_result) + STATUS download_result) list(GET download_result 0 download_code) if (NOT ${download_code} EQUAL 0) file(REMOVE ${cl2hpp_header}) #empty file have to be removed diff --git a/extern/glad/CMakeLists.txt b/extern/glad/CMakeLists.txt index c8c8d86a..4484d2f6 100644 --- a/extern/glad/CMakeLists.txt +++ b/extern/glad/CMakeLists.txt @@ -2,15 +2,19 @@ add_library(forge_glad_interface INTERFACE) target_include_directories(forge_glad_interface INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR}/include + $ ) target_sources(forge_glad_interface INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR}/src/glad.c + $ ) target_link_libraries(forge_glad_interface INTERFACE ${CMAKE_DL_LIBS} ) + +if (NOT BUILD_SHARED_LIBS) + install(TARGETS forge_glad_interface EXPORT ForgeTargets) +endif () diff --git a/src/api/c/CMakeLists.txt b/src/api/c/CMakeLists.txt index 9f4574d5..2dbee2f3 100644 --- a/src/api/c/CMakeLists.txt +++ b/src/api/c/CMakeLists.txt @@ -1,16 +1,20 @@ add_library(forge_c_api_interface INTERFACE) +# non private sources that are used for build only in INTERFACE target types +# should make sense only for builds, not when installed. Hence, wrapped with +# $ generator expression. Without it, cmake generate step +# fails when building static library. target_sources(forge_c_api_interface INTERFACE - $ - $ - $ - $ - $ - $ - $ - $ - $ + $ + $ + $ + $ + $ + $ + $ + $ + $ ) target_include_directories(forge_c_api_interface diff --git a/src/api/cpp/CMakeLists.txt b/src/api/cpp/CMakeLists.txt index c0a6ba9a..2f5b3657 100644 --- a/src/api/cpp/CMakeLists.txt +++ b/src/api/cpp/CMakeLists.txt @@ -1,22 +1,26 @@ add_library(forge_cpp_api_interface INTERFACE) +# non private sources that are used for build only in INTERFACE target types +# should make sense only for builds, not when installed. Hence, wrapped with +# $ generator expression. Without it, cmake generate step +# fails when building static library. target_sources(forge_cpp_api_interface INTERFACE - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ ) target_include_directories(forge_cpp_api_interface INTERFACE - $ + $ ) if (NOT BUILD_SHARED_LIBS) diff --git a/src/backend/CMakeLists.txt b/src/backend/CMakeLists.txt index d06241ea..52e4f0c6 100644 --- a/src/backend/CMakeLists.txt +++ b/src/backend/CMakeLists.txt @@ -10,95 +10,98 @@ add_library(${BkndTargetName} "") add_dependencies(${BkndTargetName} ${glsl_shader_targets}) -if (${FG_RENDERING_BACKEND} STREQUAL "OpenGL") - find_package(OpenGL REQUIRED) - add_subdirectory(opengl) - target_include_directories(${BkndTargetName} PUBLIC ${OPENGL_INCLUDE_DIR}) - target_link_libraries(${BkndTargetName} PUBLIC ${OPENGL_gl_LIBRARY}) -elseif (${FG_RENDERING_BACKEND} STREQUAL "Vulkan") # arm is not possible now - message(FATAL_ERROR "Vulkan rendering support not added yet") -endif () +if(${FG_RENDERING_BACKEND} STREQUAL "OpenGL") + find_package(OpenGL REQUIRED) + add_subdirectory(opengl) + target_include_directories(${BkndTargetName} PUBLIC ${OPENGL_INCLUDE_DIR}) + target_link_libraries(${BkndTargetName} PUBLIC ${OPENGL_gl_LIBRARY}) +elseif(${FG_RENDERING_BACKEND} STREQUAL "Vulkan") # arm is not possible now + message(FATAL_ERROR "Vulkan rendering support not added yet") +endif() set_target_properties(${BkndTargetName} - PROPERTIES + PROPERTIES FOLDER ${PROJECT_NAME} POSITION_INDEPENDENT_CODE ON CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON + CXX_VISIBILITY_PRESET hidden + CXX_VISIBILITY_INLINES_HIDDEN YES LINKER_LANGUAGE CXX - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR} - ) + VERSION ${Forge_VERSION} + SOVERSION ${Forge_VERSION_MAJOR} + ) -if (WIN32) - target_compile_definitions(${BkndTargetName} - PRIVATE FGDLL OS_WIN WIN32_MEAN_AND_LEAN) +if(WIN32) + target_compile_definitions(${BkndTargetName} + PRIVATE FGDLL OS_WIN WIN32_MEAN_AND_LEAN) - # C4068: Warnings about unknown pragmas - # C4275: Warnings about using non-exported classes as base class of an - # exported class - set_target_properties(${BkndTargetName} PROPERTIES COMPILE_FLAGS "/wd4068 /wd4275") -elseif (APPLE) - target_compile_definitions(${BkndTargetName} PRIVATE OS_MAC) + # C4068: Warnings about unknown pragmas + # C4275: Warnings about using non-exported classes as base class of an + # exported class + set_target_properties(${BkndTargetName} PROPERTIES COMPILE_FLAGS "/wd4068 /wd4275") +elseif(APPLE) + target_compile_definitions(${BkndTargetName} PRIVATE OS_MAC) else(WIN32) - target_compile_definitions(${BkndTargetName} PRIVATE OS_LNX) + target_compile_definitions(${BkndTargetName} PRIVATE OS_LNX) endif(WIN32) target_include_directories(${BkndTargetName} - PUBLIC - $ - $ - $ - PRIVATE - $ - SYSTEM PRIVATE + PUBLIC + $ + $ + $ + PRIVATE + $ + SYSTEM PRIVATE ${FREETYPE_INCLUDE_DIRS} - ${PROJECT_SOURCE_DIR}/extern/glm - ) + ${Forge_SOURCE_DIR}/extern/glm + ) if(FG_WITH_FREEIMAGE) - target_compile_definitions(${BkndTargetName} PRIVATE USE_FREEIMAGE) - if (FG_USE_STATIC_FREEIMAGE) - target_link_libraries(${BkndTargetName} PRIVATE FreeImage::FreeImage_STATIC) - else () - target_link_libraries(${BkndTargetName} PRIVATE FreeImage::FreeImage) - endif () + target_compile_definitions(${BkndTargetName} PRIVATE USE_FREEIMAGE) + if(FG_USE_STATIC_FREEIMAGE) + target_link_libraries(${BkndTargetName} PRIVATE FreeImage::FreeImage_STATIC) + else() + target_link_libraries(${BkndTargetName} PRIVATE FreeImage::FreeImage) + endif() endif() target_link_libraries(${BkndTargetName} - PRIVATE + PRIVATE Boost::boost forge_backend_interface forge_c_api_interface forge_cpp_api_interface forge_glad_interface forge_wtk_interface - ) + ) -if (FG_ENABLE_HUNTER) - target_link_libraries(${BkndTargetName} PRIVATE freetype::freetype) -else () - target_link_libraries(${BkndTargetName} PRIVATE ${FREETYPE_LIBRARIES}) -endif () +if(FG_ENABLE_HUNTER) + target_link_libraries(${BkndTargetName} PRIVATE freetype::freetype) +else() + target_link_libraries(${BkndTargetName} PRIVATE ${FREETYPE_LIBRARIES}) +endif() if(UNIX) - target_link_libraries(${BkndTargetName} - PRIVATE - FontConfig::FontConfig - $<$,$>:-static-libstdc++> - $<$,$>:-static-libgcc> - ) + target_link_libraries(${BkndTargetName} + PRIVATE + FontConfig::FontConfig + $<$,$>:-static-libstdc++> + $<$,$>:-static-libgcc> + ) endif(UNIX) source_group(include - REGULAR_EXPRESSION ${PROJECT_SOURCE_DIR}/include/*) + REGULAR_EXPRESSION ${Forge_SOURCE_DIR}/include/*) source_group("api\\cpp" - REGULAR_EXPRESSION ${PROJECT_SOURCE_DIR}/src/api/cpp/*) + REGULAR_EXPRESSION ${Forge_SOURCE_DIR}/src/api/cpp/*) source_group("api\\c" - REGULAR_EXPRESSION ${PROJECT_SOURCE_DIR}/src/api/c/*) + REGULAR_EXPRESSION ${Forge_SOURCE_DIR}/src/api/c/*) source_group("backend" - REGULAR_EXPRESSION ${PROJECT_SOURCE_DIR}/src/backend/common/*) + REGULAR_EXPRESSION ${Forge_SOURCE_DIR}/src/backend/common/*) source_group("backend\\shaders" - REGULAR_EXPRESSION ${PROJECT_SOURCE_DIR}/src/backend/glsl_shaders/*) + REGULAR_EXPRESSION ${Forge_SOURCE_DIR}/src/backend/glsl_shaders/*) #-------------------------------------------------------------------- # Install forge target @@ -114,9 +117,9 @@ install(TARGETS ${BkndTargetName} INCLUDES DESTINATION ${FG_INSTALL_INC_DIR}) # install dependencies -if (WIN32 AND BUILD_SHARED_LIBS AND - FG_WITH_FREEIMAGE AND NOT FG_USE_STATIC_FREEIMAGE) - install(FILES $ - DESTINATION ${FG_INSTALL_BIN_DIR} - COMPONENT dependencies) -endif () +if(WIN32 AND BUILD_SHARED_LIBS AND + FG_WITH_FREEIMAGE AND NOT FG_USE_STATIC_FREEIMAGE) + install(FILES $ + DESTINATION ${FG_INSTALL_BIN_DIR} + COMPONENT dependencies) +endif() diff --git a/src/backend/common/CMakeLists.txt b/src/backend/common/CMakeLists.txt index e10e81b7..be1e6914 100644 --- a/src/backend/common/CMakeLists.txt +++ b/src/backend/common/CMakeLists.txt @@ -1,26 +1,30 @@ add_library(forge_backend_interface INTERFACE) +# non private sources that are used for build only in INTERFACE target types +# should make sense only for builds, not when installed. Hence, wrapped with +# $ generator expression. Without it, cmake generate step +# fails when building static library. target_sources(forge_backend_interface INTERFACE - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ ) target_include_directories(forge_backend_interface INTERFACE - $ + $ ) if (NOT BUILD_SHARED_LIBS) diff --git a/src/backend/glsl_shaders/CMakeLists.txt b/src/backend/glsl_shaders/CMakeLists.txt index c6267c14..28aec4f5 100644 --- a/src/backend/glsl_shaders/CMakeLists.txt +++ b/src/backend/glsl_shaders/CMakeLists.txt @@ -1,4 +1,4 @@ -add_executable(glsl2cpp "${PROJECT_SOURCE_DIR}/CMakeModules/glsl2cpp.cpp") +add_executable(glsl2cpp "${Forge_SOURCE_DIR}/CMakeModules/glsl2cpp.cpp") set_target_properties(glsl2cpp PROPERTIES CXX_STANDARD 11) @@ -17,5 +17,5 @@ convert_glsl_shaders_to_headers( OUTPUT_DIR "include/shader_headers" TARGETS glsl_shader_targets NAMESPACE "glsl" - EOD "0" + EOF "0" ) diff --git a/src/backend/opengl/CMakeLists.txt b/src/backend/opengl/CMakeLists.txt index 828e8756..1a5ab6cf 100755 --- a/src/backend/opengl/CMakeLists.txt +++ b/src/backend/opengl/CMakeLists.txt @@ -1,52 +1,52 @@ -target_include_directories(${BkndTargetName} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(${BkndTargetName} + PRIVATE ${CMAKE_CURRENT_LIST_DIR} + ) target_sources(${BkndTargetName} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/abstract_renderable.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/backend.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/chart_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/chart_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/colormap_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/colormap_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/gl_helpers.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/gl_helpers.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/font_atlas_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/font_atlas_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/font_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/font_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/gl_native_handles.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/gl_native_handles.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/histogram_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/histogram_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/image_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/image_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/plot_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/plot_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/shader_program.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/shader_program.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/surface_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/surface_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/update_buffer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/vector_field_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/vector_field_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/window_impl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/window_impl.cpp - ) + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/abstract_renderable.hpp + ${CMAKE_CURRENT_LIST_DIR}/backend.hpp + ${CMAKE_CURRENT_LIST_DIR}/chart_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/chart_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/colormap_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/colormap_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/gl_helpers.hpp + ${CMAKE_CURRENT_LIST_DIR}/gl_helpers.cpp + ${CMAKE_CURRENT_LIST_DIR}/font_atlas_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/font_atlas_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/font_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/font_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/gl_native_handles.hpp + ${CMAKE_CURRENT_LIST_DIR}/gl_native_handles.cpp + ${CMAKE_CURRENT_LIST_DIR}/histogram_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/histogram_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/image_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/image_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/plot_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/plot_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/shader_program.hpp + ${CMAKE_CURRENT_LIST_DIR}/shader_program.cpp + ${CMAKE_CURRENT_LIST_DIR}/surface_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/surface_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/update_buffer.cpp + ${CMAKE_CURRENT_LIST_DIR}/vector_field_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/vector_field_impl.cpp + ${CMAKE_CURRENT_LIST_DIR}/window_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/window_impl.cpp + ) if(${FG_USE_WINDOW_TOOLKIT} STREQUAL "glfw3") - add_subdirectory(glfw) - target_compile_definitions(${BkndTargetName} PRIVATE USE_GLFW) + include(glfw/CMakeLists.txt) elseif(${FG_USE_WINDOW_TOOLKIT} STREQUAL "sdl2") - add_subdirectory(sdl) - target_compile_definitions(${BkndTargetName} PRIVATE USE_SDL) + include(sdl/CMakeLists.txt) endif() source_group("backend" - REGULAR_EXPRESSION ${CMAKE_CURRENT_SOURCE_DIR}/*) + REGULAR_EXPRESSION ${CMAKE_CURRENT_LIST_DIR}/*) if(${FG_USE_WINDOW_TOOLKIT} STREQUAL "glfw3") - source_group("backend\\glfw" - REGULAR_EXPRESSION ${PROJECT_SOURCE_DIR}/src/backend/opengl/glfw/*) + source_group("backend\\glfw" + REGULAR_EXPRESSION ${Forge_SOURCE_DIR}/src/backend/opengl/glfw/*) elseif(${FG_USE_WINDOW_TOOLKIT} STREQUAL "sdl2") - source_group("backend\\sdl2" - REGULAR_EXPRESSION ${PROJECT_SOURCE_DIR}/src/backend/opengl/sdl/*) + source_group("backend\\sdl2" + REGULAR_EXPRESSION ${Forge_SOURCE_DIR}/src/backend/opengl/sdl/*) endif() diff --git a/src/backend/opengl/glfw/CMakeLists.txt b/src/backend/opengl/glfw/CMakeLists.txt index 3c8d71ca..0b1b2bcf 100644 --- a/src/backend/opengl/glfw/CMakeLists.txt +++ b/src/backend/opengl/glfw/CMakeLists.txt @@ -8,24 +8,23 @@ endif() add_library(forge_wtk_interface INTERFACE) target_include_directories(forge_wtk_interface - INTERFACE - $ + INTERFACE $ ) target_sources(forge_wtk_interface INTERFACE - $ - $ + $ + $ ) target_link_libraries(forge_wtk_interface INTERFACE glfw) -if (NOT BUILD_SHARED_LIBS) +if(NOT BUILD_SHARED_LIBS) install(TARGETS forge_wtk_interface EXPORT ForgeTargets) -endif () +endif() -if (WIN32 AND BUILD_SHARED_LIBS) +if(WIN32 AND BUILD_SHARED_LIBS) install(FILES $ DESTINATION ${FG_INSTALL_BIN_DIR} COMPONENT dependencies) -endif () +endif() diff --git a/src/backend/opengl/sdl/CMakeLists.txt b/src/backend/opengl/sdl/CMakeLists.txt index d55f27dc..3ccae7e6 100644 --- a/src/backend/opengl/sdl/CMakeLists.txt +++ b/src/backend/opengl/sdl/CMakeLists.txt @@ -8,24 +8,23 @@ endif() add_library(forge_wtk_interface INTERFACE) target_include_directories(forge_wtk_interface - INTERFACE - $ + INTERFACE $ ) target_sources(forge_wtk_interface INTERFACE - $ - $ + $ + $ ) target_link_libraries(forge_wtk_interface INTERFACE SDL2::SDL2) -if (NOT BUILD_SHARED_LIBS) +if(NOT BUILD_SHARED_LIBS) install(TARGETS forge_wtk_interface EXPORT ForgeTargets) -endif () +endif() -if (WIN32 AND BUILD_SHARED_LIBS) +if(WIN32 AND BUILD_SHARED_LIBS) install(FILES $ DESTINATION ${FG_INSTALL_BIN_DIR} COMPONENT dependencies) -endif () +endif() diff --git a/src/backend/opengl/window_impl.hpp b/src/backend/opengl/window_impl.hpp index 7d973c72..6e865421 100644 --- a/src/backend/opengl/window_impl.hpp +++ b/src/backend/opengl/window_impl.hpp @@ -9,11 +9,8 @@ #pragma once -#if defined(USE_GLFW) -#include -#elif defined(USE_SDL) -#include -#endif +#include + #include #include #include From dbc3f0dadc1cbdd6ee965789f258fbd254617ce2 Mon Sep 17 00:00:00 2001 From: pradeep Date: Thu, 13 Feb 2020 16:02:41 +0530 Subject: [PATCH 2/2] Remove hunter support Hunter is adding extra maintenance at the moment which can be easily replaced by vcpkg. vcpkg has much larger set of packages and easy to integrate with the existing cmake code. --- CMakeLists.txt | 34 +- CMakeModules/Hunter/config.cmake | 59 -- CMakeModules/HunterGate.cmake | 511 ------------------ examples/CMakeLists.txt | 2 +- .../{FindOpenGL.cmake => Findopengl.cmake} | 0 src/backend/CMakeLists.txt | 10 +- src/backend/opengl/glfw/CMakeLists.txt | 7 +- src/backend/opengl/sdl/CMakeLists.txt | 7 +- 8 files changed, 14 insertions(+), 616 deletions(-) delete mode 100644 CMakeModules/Hunter/config.cmake delete mode 100644 CMakeModules/HunterGate.cmake rename examples/CMakeModules/{FindOpenGL.cmake => Findopengl.cmake} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9deb7631..12a24052 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,36 +16,18 @@ include(ForgeVersion) set_policies(TYPE NEW POLICIES CMP0072 CMP0077) option(BUILD_SHARED_LIBS "Build shared/static library" ON) -option(FG_ENABLE_HUNTER "Use Hunter cmake package handler" OFF) - -if(FG_ENABLE_HUNTER) - set(HUNTER_TLS_VERIFY OFF) - set(HUNTER_BUILD_SHARED_LIBS OFF) - include(${CMAKE_CURRENT_LIST_DIR}/CMakeModules/HunterGate.cmake) - HunterGate( - URL "https://github.com/ruslo/hunter/archive/v0.20.60.tar.gz" - SHA1 "35a23a3e2f8a2c87f6762c43f3cc64a0bee50943" - FILEPATH "${CMAKE_CURRENT_LIST_DIR}/CMakeModules/Hunter/config.cmake" - ) - mark_as_advanced(HUNTER_TLS_VERIFY) - mark_as_advanced(HUNTER_BUILD_SHARED_LIBS) - - hunter_add_package(freetype) - hunter_add_package(Boost) - - find_package(freetype CONFIG REQUIRED NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH) - find_package(Boost REQUIRED NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH) -else() - find_package(Freetype REQUIRED) - find_package(Boost REQUIRED) -endif() -#packages not available via hunter +find_package(Boost REQUIRED) find_package(Doxygen QUIET) -find_package(Sphinx QUIET) +find_package(FontConfig QUIET) find_package(FreeImage QUIET) +find_package(Freetype REQUIRED) +find_package(OpenGL QUIET) +find_package(Sphinx QUIET) + if(UNIX) - find_package(FontConfig REQUIRED) + dependency_check(FontConfig_FOUND + "FontConfig is required on non-windows OS") endif() option(FG_BUILD_DOCS diff --git a/CMakeModules/Hunter/config.cmake b/CMakeModules/Hunter/config.cmake deleted file mode 100644 index 0506cdd5..00000000 --- a/CMakeModules/Hunter/config.cmake +++ /dev/null @@ -1,59 +0,0 @@ -include(hunter_config) - -macro(myhunter_config pkg_name ver) - hunter_config( - ${pkg_name} - VERSION ${ver} - CONFIGURATION_TYPES Release - CMAKE_ARGS CMAKE_POSITION_INDEPENDENT_CODE=ON ${ARGN} - ) - mark_as_advanced(${pkg_name}_DIR) -endmacro() - -myhunter_config(Boost 1.66.0) -myhunter_config(freetype 2.6.2) -myhunter_config(OpenCL 2.1-p0) - -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.2.0") - myhunter_config(glm 0.9.7.6) - else() - myhunter_config(glm 0.9.8.5) - endif() -endif () - -#myhunter_config(freeimage hunter-v3.17.0) -##freeimag dependencies -#myhunter_config(ZLIB 1.2.8-p3) -#myhunter_config(TIFF 4.0.2-p3) -#myhunter_config(PNG 1.6.26-p1) -#myhunter_config(Jpeg 9b-p3) - -#glfw dependencies -myhunter_config(xcursor 1.1.13) -myhunter_config(xorg-macros 1.17) -myhunter_config(xrender 0.9.7) -myhunter_config(x11 1.5.0) -myhunter_config(xproto 7.0.23) -myhunter_config(xextproto 7.2.1) -myhunter_config(xtrans 1.2.7) -myhunter_config(xcb 1.11.1) -myhunter_config(xcb-proto 1.11) -myhunter_config(pthread-stubs 0.3) -myhunter_config(xau 1.0.7) -myhunter_config(kbproto 1.0.6) -myhunter_config(inputproto 2.2) -myhunter_config(renderproto 0.11.1) -myhunter_config(xfixes 5.0.1) -myhunter_config(fixesproto 5.0) -myhunter_config(xinerama 1.1.2) -myhunter_config(xineramaproto 1.1.2) -myhunter_config(xrandr 1.3.2) -myhunter_config(randrproto 1.3.2) -myhunter_config(xi 1.6.1) -myhunter_config(xext 1.3.1) - -myhunter_config(glfw 3.3.0-p2 - GLFW_BUILD_DOCS=OFF - GLFW_BUILD_EXAMPLES=OFF - GLFW_BUILD_TESTS=OFF) diff --git a/CMakeModules/HunterGate.cmake b/CMakeModules/HunterGate.cmake deleted file mode 100644 index 27094874..00000000 --- a/CMakeModules/HunterGate.cmake +++ /dev/null @@ -1,511 +0,0 @@ -# Copyright (c) 2013-2015, Ruslan Baratov -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# This is a gate file to Hunter package manager. -# Include this file using `include` command and add package you need, example: -# -# cmake_minimum_required(VERSION 3.0) -# -# include("cmake/HunterGate.cmake") -# HunterGate( -# URL "https://github.com/path/to/hunter/archive.tar.gz" -# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d" -# ) -# -# project(MyProject) -# -# hunter_add_package(Foo) -# hunter_add_package(Boo COMPONENTS Bar Baz) -# -# Projects: -# * https://github.com/hunter-packages/gate/ -# * https://github.com/ruslo/hunter - -cmake_minimum_required(VERSION 3.0) # Minimum for Hunter - -# min cmake required for forge is 3.5, hence -# no need to include the below module to use cmake_parse_arguments -# include(CMakeParseArguments) - -option(HUNTER_ENABLED "Enable Hunter package manager support" ON) -option(HUNTER_STATUS_PRINT "Print working status" ON) -option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) - -set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki") - -function(hunter_gate_status_print) - foreach(print_message ${ARGV}) - if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) - message(STATUS "[hunter] ${print_message}") - endif() - endforeach() -endfunction() - -function(hunter_gate_status_debug) - foreach(print_message ${ARGV}) - if(HUNTER_STATUS_DEBUG) - string(TIMESTAMP timestamp) - message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") - endif() - endforeach() -endfunction() - -function(hunter_gate_wiki wiki_page) - message("------------------------------ WIKI -------------------------------") - message(" ${HUNTER_WIKI}/${wiki_page}") - message("-------------------------------------------------------------------") - message("") - message(FATAL_ERROR "") -endfunction() - -function(hunter_gate_internal_error) - message("") - foreach(print_message ${ARGV}) - message("[hunter ** INTERNAL **] ${print_message}") - endforeach() - message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") - message("") - hunter_gate_wiki("error.internal") -endfunction() - -function(hunter_gate_fatal_error) - cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}") - string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki) - if(have_no_wiki) - hunter_gate_internal_error("Expected wiki") - endif() - message("") - foreach(x ${hunter_UNPARSED_ARGUMENTS}) - message("[hunter ** FATAL ERROR **] ${x}") - endforeach() - message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") - message("") - hunter_gate_wiki("${hunter_WIKI}") -endfunction() - -function(hunter_gate_user_error) - hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data") -endfunction() - -function(hunter_gate_self root version sha1 result) - string(COMPARE EQUAL "${root}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("root is empty") - endif() - - string(COMPARE EQUAL "${version}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("version is empty") - endif() - - string(COMPARE EQUAL "${sha1}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("sha1 is empty") - endif() - - string(SUBSTRING "${sha1}" 0 7 archive_id) - - if(EXISTS "${root}/cmake/Hunter") - set(hunter_self "${root}") - else() - set( - hunter_self - "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" - ) - endif() - - set("${result}" "${hunter_self}" PARENT_SCOPE) -endfunction() - -# Set HUNTER_GATE_ROOT cmake variable to suitable value. -function(hunter_gate_detect_root) - # Check CMake variable - string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty) - if(not_empty) - set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable") - return() - endif() - - # Check environment variable - string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty) - if(not_empty) - set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT detected by environment variable") - return() - endif() - - # Check HOME environment variable - string(COMPARE NOTEQUAL "$ENV{HOME}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable") - return() - endif() - - # Check SYSTEMDRIVE and USERPROFILE environment variable (windows only) - if(WIN32) - string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug( - "HUNTER_ROOT set using SYSTEMDRIVE environment variable" - ) - return() - endif() - - string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug( - "HUNTER_ROOT set using USERPROFILE environment variable" - ) - return() - endif() - endif() - - hunter_gate_fatal_error( - "Can't detect HUNTER_ROOT" - WIKI "error.detect.hunter.root" - ) -endfunction() - -macro(hunter_gate_lock dir) - if(NOT HUNTER_SKIP_LOCK) - if("${CMAKE_VERSION}" VERSION_LESS "3.2") - hunter_gate_fatal_error( - "Can't lock, upgrade to CMake 3.2 or use HUNTER_SKIP_LOCK" - WIKI "error.can.not.lock" - ) - endif() - hunter_gate_status_debug("Locking directory: ${dir}") - file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) - hunter_gate_status_debug("Lock done") - endif() -endmacro() - -function(hunter_gate_download dir) - string( - COMPARE - NOTEQUAL - "$ENV{HUNTER_DISABLE_AUTOINSTALL}" - "" - disable_autoinstall - ) - if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL) - hunter_gate_fatal_error( - "Hunter not found in '${dir}'" - "Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'" - "Settings:" - " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" - " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" - WIKI "error.run.install" - ) - endif() - string(COMPARE EQUAL "${dir}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("Empty 'dir' argument") - endif() - - string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("HUNTER_GATE_SHA1 empty") - endif() - - string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("HUNTER_GATE_URL empty") - endif() - - set(done_location "${dir}/DONE") - set(sha1_location "${dir}/SHA1") - - set(build_dir "${dir}/Build") - set(cmakelists "${dir}/CMakeLists.txt") - - hunter_gate_lock("${dir}") - if(EXISTS "${done_location}") - # while waiting for lock other instance can do all the job - hunter_gate_status_debug("File '${done_location}' found, skip install") - return() - endif() - - file(REMOVE_RECURSE "${build_dir}") - file(REMOVE_RECURSE "${cmakelists}") - - file(MAKE_DIRECTORY "${build_dir}") # check directory permissions - - # Disabling languages speeds up a little bit, reduces noise in the output - # and avoids path too long windows error - file( - WRITE - "${cmakelists}" - "cmake_minimum_required(VERSION 3.0)\n" - "project(HunterDownload LANGUAGES NONE)\n" - "include(ExternalProject)\n" - "ExternalProject_Add(\n" - " Hunter\n" - " URL\n" - " \"${HUNTER_GATE_URL}\"\n" - " URL_HASH\n" - " SHA1=${HUNTER_GATE_SHA1}\n" - " DOWNLOAD_DIR\n" - " \"${dir}\"\n" - " SOURCE_DIR\n" - " \"${dir}/Unpacked\"\n" - " CONFIGURE_COMMAND\n" - " \"\"\n" - " BUILD_COMMAND\n" - " \"\"\n" - " INSTALL_COMMAND\n" - " \"\"\n" - ")\n" - ) - - if(HUNTER_STATUS_DEBUG) - set(logging_params "") - else() - set(logging_params OUTPUT_QUIET) - endif() - - hunter_gate_status_debug("Run generate") - - # Need to add toolchain file too. - # Otherwise on Visual Studio + MDD this will fail with error: - # "Could not find an appropriate version of the Windows 10 SDK installed on this machine" - if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") - set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") - else() - # 'toolchain_arg' can't be empty - set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=") - endif() - - execute_process( - COMMAND "${CMAKE_COMMAND}" "-H${dir}" "-B${build_dir}" "-G${CMAKE_GENERATOR}" "${toolchain_arg}" - WORKING_DIRECTORY "${dir}" - RESULT_VARIABLE download_result - ${logging_params} - ) - - if(NOT download_result EQUAL 0) - hunter_gate_internal_error("Configure project failed") - endif() - - hunter_gate_status_print( - "Initializing Hunter workspace (${HUNTER_GATE_SHA1})" - " ${HUNTER_GATE_URL}" - " -> ${dir}" - ) - execute_process( - COMMAND "${CMAKE_COMMAND}" --build "${build_dir}" - WORKING_DIRECTORY "${dir}" - RESULT_VARIABLE download_result - ${logging_params} - ) - - if(NOT download_result EQUAL 0) - hunter_gate_internal_error("Build project failed") - endif() - - file(REMOVE_RECURSE "${build_dir}") - file(REMOVE_RECURSE "${cmakelists}") - - file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}") - file(WRITE "${done_location}" "DONE") - - hunter_gate_status_debug("Finished") -endfunction() - -# Must be a macro so master file 'cmake/Hunter' can -# apply all variables easily just by 'include' command -# (otherwise PARENT_SCOPE magic needed) -macro(HunterGate) - if(HUNTER_GATE_DONE) - # variable HUNTER_GATE_DONE set explicitly for external project - # (see `hunter_download`) - set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) - endif() - - # First HunterGate command will init Hunter, others will be ignored - get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET) - - if(NOT HUNTER_ENABLED) - # Empty function to avoid error "unknown function" - function(hunter_add_package) - endfunction() - elseif(_hunter_gate_done) - hunter_gate_status_debug("Secondary HunterGate (use old settings)") - hunter_gate_self( - "${HUNTER_CACHED_ROOT}" - "${HUNTER_VERSION}" - "${HUNTER_SHA1}" - _hunter_self - ) - include("${_hunter_self}/cmake/Hunter") - else() - set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_DIR}") - - string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name) - if(_have_project_name) - hunter_gate_fatal_error( - "Please set HunterGate *before* 'project' command. " - "Detected project: ${PROJECT_NAME}" - WIKI "error.huntergate.before.project" - ) - endif() - - cmake_parse_arguments( - HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV} - ) - - string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1) - string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url) - string( - COMPARE - NOTEQUAL - "${HUNTER_GATE_UNPARSED_ARGUMENTS}" - "" - _have_unparsed - ) - string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global) - string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath) - - if(_have_unparsed) - hunter_gate_user_error( - "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" - ) - endif() - if(_empty_sha1) - hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory") - endif() - if(_empty_url) - hunter_gate_user_error("URL suboption of HunterGate is mandatory") - endif() - if(_have_global) - if(HUNTER_GATE_LOCAL) - hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)") - endif() - if(_have_filepath) - hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)") - endif() - endif() - if(HUNTER_GATE_LOCAL) - if(_have_global) - hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)") - endif() - if(_have_filepath) - hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)") - endif() - endif() - if(_have_filepath) - if(_have_global) - hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)") - endif() - if(HUNTER_GATE_LOCAL) - hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)") - endif() - endif() - - hunter_gate_detect_root() # set HUNTER_GATE_ROOT - - # Beautify path, fix probable problems with windows path slashes - get_filename_component( - HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE - ) - hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}") - if(NOT HUNTER_ALLOW_SPACES_IN_PATH) - string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces) - if(NOT _contain_spaces EQUAL -1) - hunter_gate_fatal_error( - "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." - "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" - "(Use at your own risk!)" - WIKI "error.spaces.in.hunter.root" - ) - endif() - endif() - - string( - REGEX - MATCH - "[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*" - HUNTER_GATE_VERSION - "${HUNTER_GATE_URL}" - ) - string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty) - if(_is_empty) - set(HUNTER_GATE_VERSION "unknown") - endif() - - hunter_gate_self( - "${HUNTER_GATE_ROOT}" - "${HUNTER_GATE_VERSION}" - "${HUNTER_GATE_SHA1}" - _hunter_self - ) - - set(_master_location "${_hunter_self}/cmake/Hunter") - if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") - # Hunter downloaded manually (e.g. by 'git clone') - set(_unused "xxxxxxxxxx") - set(HUNTER_GATE_SHA1 "${_unused}") - set(HUNTER_GATE_VERSION "${_unused}") - else() - get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) - set(_done_location "${_archive_id_location}/DONE") - set(_sha1_location "${_archive_id_location}/SHA1") - - # Check Hunter already downloaded by HunterGate - if(NOT EXISTS "${_done_location}") - hunter_gate_download("${_archive_id_location}") - endif() - - if(NOT EXISTS "${_done_location}") - hunter_gate_internal_error("hunter_gate_download failed") - endif() - - if(NOT EXISTS "${_sha1_location}") - hunter_gate_internal_error("${_sha1_location} not found") - endif() - file(READ "${_sha1_location}" _sha1_value) - string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal) - if(NOT _is_equal) - hunter_gate_internal_error( - "Short SHA1 collision:" - " ${_sha1_value} (from ${_sha1_location})" - " ${HUNTER_GATE_SHA1} (HunterGate)" - ) - endif() - if(NOT EXISTS "${_master_location}") - hunter_gate_user_error( - "Master file not found:" - " ${_master_location}" - "try to update Hunter/HunterGate" - ) - endif() - endif() - include("${_master_location}") - set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) - endif() -endmacro() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 87d029bf..2d0915d6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -14,7 +14,7 @@ endif() find_package(OpenCL 1.2 QUIET) find_package(CUDA QUIET) -find_package(OpenGL REQUIRED) +find_package(opengl REQUIRED) #This uses custom module shipped with examples find_package(Forge REQUIRED) mark_as_advanced( diff --git a/examples/CMakeModules/FindOpenGL.cmake b/examples/CMakeModules/Findopengl.cmake similarity index 100% rename from examples/CMakeModules/FindOpenGL.cmake rename to examples/CMakeModules/Findopengl.cmake diff --git a/src/backend/CMakeLists.txt b/src/backend/CMakeLists.txt index 52e4f0c6..12eafe8e 100644 --- a/src/backend/CMakeLists.txt +++ b/src/backend/CMakeLists.txt @@ -11,7 +11,8 @@ add_library(${BkndTargetName} "") add_dependencies(${BkndTargetName} ${glsl_shader_targets}) if(${FG_RENDERING_BACKEND} STREQUAL "OpenGL") - find_package(OpenGL REQUIRED) + dependency_check(OPENGL_FOUND + "OpenGL rendering backend requires platform specific opengl library") add_subdirectory(opengl) target_include_directories(${BkndTargetName} PUBLIC ${OPENGL_INCLUDE_DIR}) target_link_libraries(${BkndTargetName} PUBLIC ${OPENGL_gl_LIBRARY}) @@ -70,6 +71,7 @@ endif() target_link_libraries(${BkndTargetName} PRIVATE Boost::boost + ${FREETYPE_LIBRARIES} forge_backend_interface forge_c_api_interface forge_cpp_api_interface @@ -77,12 +79,6 @@ target_link_libraries(${BkndTargetName} forge_wtk_interface ) -if(FG_ENABLE_HUNTER) - target_link_libraries(${BkndTargetName} PRIVATE freetype::freetype) -else() - target_link_libraries(${BkndTargetName} PRIVATE ${FREETYPE_LIBRARIES}) -endif() - if(UNIX) target_link_libraries(${BkndTargetName} PRIVATE diff --git a/src/backend/opengl/glfw/CMakeLists.txt b/src/backend/opengl/glfw/CMakeLists.txt index 0b1b2bcf..3828a872 100644 --- a/src/backend/opengl/glfw/CMakeLists.txt +++ b/src/backend/opengl/glfw/CMakeLists.txt @@ -1,9 +1,4 @@ -if(FG_ENABLE_HUNTER) - hunter_add_package(glfw) - find_package(glfw3 NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH) -else () - find_package(glfw3) -endif() +find_package(glfw3) add_library(forge_wtk_interface INTERFACE) diff --git a/src/backend/opengl/sdl/CMakeLists.txt b/src/backend/opengl/sdl/CMakeLists.txt index 3ccae7e6..8efde401 100644 --- a/src/backend/opengl/sdl/CMakeLists.txt +++ b/src/backend/opengl/sdl/CMakeLists.txt @@ -1,9 +1,4 @@ -if(FG_ENABLE_HUNTER) - hunter_add_package(SDL2) - find_package(SDL2 NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH) -else() - find_package(SDL2) -endif() +find_package(SDL2) add_library(forge_wtk_interface INTERFACE)