Scripts/GorgonConfig.cmake.in

Sat, 27 Nov 2021 15:02:03 +0100

author
cengizkandemir
date
Sat, 27 Nov 2021 15:02:03 +0100
branch
4.x-dev
changeset 1764
e47116c2f9a3
parent 1625
f1512f7188c2
permissions
-rw-r--r--

Include gorgon dirs to the target as system to avoid compilation issues

# - Config file for the Gorgon package
# It defines the following variables
#  GORGON_INCLUDE_DIRS - include directories for Gorgon Library
#  GORGON_LIBRARIES    - libraries to link against
 
include("${CMAKE_CURRENT_LIST_DIR}/GorgonTargets.cmake")

# Compute paths
get_filename_component(GORGON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(GORGON_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")

# These are IMPORTED targets created by GorgonTargets.cmake
set(GORGON_LIBRARIES Gorgon)
set(GORGON_EXECUTABLE )

MACRO(compilersetup)

	if(UNIX) 
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLINUX -Werror=return-type")
	else()
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800")
	endif()

	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLM_SWIZZLE -DGLM_FORCE_RADIANS")

	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENGL @ADDITIONAL_CLIENT_FLAGS@")

	#compiler check
	IF(CMAKE_COMPILER_IS_GNUCXX)
		EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
		
		IF(GCC_VERSION VERSION_LESS 4.8)
			IF(IGNORE_COMPILER_VERSION)
				MESSAGE(STATUS "Gorgon Library requires GCC 4.8+")
			ELSE()
				MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VERSION=ON to continue anyway")
				MESSAGE(FATAL_ERROR "Gorgon Library requires GCC 4.8+")
			ENDIF()
		ENDIF()
	ELSEIF(MSVC)
		IF(MSVC_VERSION VERSION_LESS 14)
			IF(IGNORE_COMPILER_VERSION)
				MESSAGE(STATUS "Gorgon Library requires Visual Studio 2015+")
			ELSE()
				MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VERSION=ON to continue anyway")
				MESSAGE(FATAL_ERROR "Gorgon Library requires Visual Studio 2015+")
			ENDIF()
		ENDIF()
	ELSE()
		IF(IGNORE_COMPILER_VENDOR)
			MESSAGE(STATUS "Unsupported compiler! Gorgon Library requires GCC 4.8+ OR Visual Studio 2015+")
			MESSAGE(STATUS "You may need to manually activate C++14 features")
		ELSE()
			MESSAGE(STATUS "use cmake -DIGNORE_COMPILER_VENDOR=ON to continue anyway")
			MESSAGE(FATAL_ERROR "Unsupported compiler! Gorgon Library requires GCC 4.8+ OR Visual Studio 2015+")
		ENDIF()
	ENDIF()

	OPTION(FORCE_32_BIT "Force 32 bit compilation" OFF)

	#enable C++11 and 32-bit compilation
	INCLUDE(CheckCXXCompilerFlag)
	IF(CMAKE_COMPILER_IS_GNUCXX)
		IF(${FORCE_32_BIT})
			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
			SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
		ELSE()
			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
		ENDIF()
	ENDIF()

	IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
		IF(${FORCE_32_BIT})
			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
			SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
		ELSE()
			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
		ENDIF()
	ENDIF()

	#MACRO(FixProject) 
	#ENDMACRO()

	IF(MSVC)
		ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
	
		ADD_DEFINITIONS(-DUNICODE)
		ADD_DEFINITIONS(-D_UNICODE)
		
		SET(configs
		CMAKE_C_FLAGS_DEBUG
		CMAKE_C_FLAGS_MINSIZEREL
		CMAKE_C_FLAGS_RELEASE
		CMAKE_C_FLAGS_RELWITHDEBINFO
		CMAKE_CXX_FLAGS_DEBUG
		CMAKE_CXX_FLAGS_MINSIZEREL
		CMAKE_CXX_FLAGS_RELEASE
		CMAKE_CXX_FLAGS_RELWITHDEBINFO
		)
		
		FOREACH(config ${configs})
		IF(${config} MATCHES "/MD")
			STRING(REGEX REPLACE "/MD" "/MT" ${config} "${${config}}")
		ENDIF()
		ENDFOREACH()
		
		IF(${CMAKE_CL_64} AND ${FORCE_32_BIT})
			MESSAGE(FATAL_ERROR "Gorgon Library forced to work with 32 bit compilation")
		ENDIF()
	ENDIF()
ENDMACRO()

MACRO(linkgorgon target)
	compilersetup()
	target_link_libraries(${target} Gorgon)
	
	target_include_directories(${target} SYSTEM PRIVATE ${GORGON_INCLUDE_DIRS})
	
    if("@FREETYPE@" STREQUAL "SYSTEM" OR "@FREETYPE@" STREQUAL "BUILTIN")
        set(FREETYPE_INCLUDE_DIRS "@FREETYPE_INCLUDE_DIRS@")
    endif()
ENDMACRO()

mercurial