diff --git a/upEngine/CMake/CMakeParseArguments.cmake b/upEngine/CMake/CMakeParseArguments.cmake new file mode 100644 index 0000000..406780e --- /dev/null +++ b/upEngine/CMake/CMakeParseArguments.cmake @@ -0,0 +1,138 @@ +# CMAKE_PARSE_ARGUMENTS( args...) +# +# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for +# parsing the arguments given to that macro or function. +# It processes the arguments and defines a set of variables which hold the +# values of the respective options. +# +# The argument contains all options for the respective macro, +# i.e. keywords which can be used when calling the macro without any value +# following, like e.g. the OPTIONAL keyword of the install() command. +# +# The argument contains all keywords for this macro +# which are followed by one value, like e.g. DESTINATION keyword of the +# install() command. +# +# The argument contains all keywords for this macro +# which can be followed by more than one value, like e.g. the TARGETS or +# FILES keywords of the install() command. +# +# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the +# keywords listed in , and +# a variable composed of the given +# followed by "_" and the name of the respective keyword. +# These variables will then hold the respective value from the argument list. +# For the keywords this will be TRUE or FALSE. +# +# All remaining arguments are collected in a variable +# _UNPARSED_ARGUMENTS, this can be checked afterwards to see whether +# your macro was called with unrecognized parameters. +# +# As an example here a my_install() macro, which takes similar arguments as the +# real install() command: +# +# function(MY_INSTALL) +# set(options OPTIONAL FAST) +# set(oneValueArgs DESTINATION RENAME) +# set(multiValueArgs TARGETS CONFIGURATIONS) +# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) +# ... +# +# Assume my_install() has been called like this: +# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) +# +# After the cmake_parse_arguments() call the macro will have set the following +# variables: +# MY_INSTALL_OPTIONAL = TRUE +# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() +# MY_INSTALL_DESTINATION = "bin" +# MY_INSTALL_RENAME = "" (was not used) +# MY_INSTALL_TARGETS = "foo;bar" +# MY_INSTALL_CONFIGURATIONS = "" (was not used) +# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" +# +# You can the continue and process these variables. +# +# Keywords terminate lists of values, e.g. if directly after a one_value_keyword +# another recognized keyword follows, this is interpreted as the beginning of +# the new option. +# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in +# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would +# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. + +#============================================================================= +# Copyright 2010 Alexander Neundorf +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + + +if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) + return() +endif() +set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) + + +function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) + # first set all result variables to empty/FALSE + foreach(arg_name ${_singleArgNames} ${_multiArgNames}) + set(${prefix}_${arg_name}) + endforeach() + + foreach(option ${_optionNames}) + set(${prefix}_${option} FALSE) + endforeach() + + set(${prefix}_UNPARSED_ARGUMENTS) + + set(insideValues FALSE) + set(currentArgName) + + # now iterate over all arguments and fill the result variables + foreach(currentArg ${ARGN}) + list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword + + if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) + if(insideValues) + if("${insideValues}" STREQUAL "SINGLE") + set(${prefix}_${currentArgName} ${currentArg}) + set(insideValues FALSE) + elseif("${insideValues}" STREQUAL "MULTI") + list(APPEND ${prefix}_${currentArgName} ${currentArg}) + endif() + else() + list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) + endif() + else() + if(NOT ${optionIndex} EQUAL -1) + set(${prefix}_${currentArg} TRUE) + set(insideValues FALSE) + elseif(NOT ${singleArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "SINGLE") + elseif(NOT ${multiArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "MULTI") + endif() + endif() + + endforeach() + + # propagate the result variables to the caller: + foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) + set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) + endforeach() + set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + +endfunction() diff --git a/upEngine/CMake/FindFreeImage.cmake b/upEngine/CMake/FindFreeImage.cmake new file mode 100644 index 0000000..f3ef3d9 --- /dev/null +++ b/upEngine/CMake/FindFreeImage.cmake @@ -0,0 +1,49 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# - Try to find FreeImage +# Once done, this will define +# +# FreeImage_FOUND - system has FreeImage +# FreeImage_INCLUDE_DIRS - the FreeImage include directories +# FreeImage_LIBRARIES - link these to use FreeImage + +include(FindPkgMacros) +findpkg_begin(FreeImage) + +# Get path, convert backslashes as ${ENV_${var}} +getenv_path(FREEIMAGE_HOME) + +# construct search paths +set(FreeImage_PREFIX_PATH ${FREEIMAGE_HOME} ${ENV_FREEIMAGE_HOME}) +create_search_paths(FreeImage) +# redo search if prefix path changed +clear_if_changed(FreeImage_PREFIX_PATH + FreeImage_LIBRARY_FWK + FreeImage_LIBRARY_REL + FreeImage_LIBRARY_DBG + FreeImage_INCLUDE_DIR +) + +set(FreeImage_LIBRARY_NAMES freeimage freeimageLib) +get_debug_names(FreeImage_LIBRARY_NAMES) + +use_pkgconfig(FreeImage_PKGC freeimage) + +findpkg_framework(FreeImage) + +find_path(FreeImage_INCLUDE_DIR NAMES FreeImage.h HINTS ${FreeImage_INC_SEARCH_PATH} ${FreeImage_PKGC_INCLUDE_DIRS}) + +find_library(FreeImage_LIBRARY_REL NAMES ${FreeImage_LIBRARY_NAMES} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) +find_library(FreeImage_LIBRARY_DBG NAMES ${FreeImage_LIBRARY_NAMES_DBG} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) + +make_library_set(FreeImage_LIBRARY) + +findpkg_finish(FreeImage) + diff --git a/upEngine/CMake/FindPackageHandleStandardArgs.cmake b/upEngine/CMake/FindPackageHandleStandardArgs.cmake new file mode 100644 index 0000000..70423a7 --- /dev/null +++ b/upEngine/CMake/FindPackageHandleStandardArgs.cmake @@ -0,0 +1,323 @@ +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... ) +# +# This function is intended to be used in FindXXX.cmake modules files. +# It handles the REQUIRED, QUIET and version-related arguments to find_package(). +# It also sets the _FOUND variable. +# The package is considered found if all variables ... listed contain +# valid results, e.g. valid filepaths. +# +# There are two modes of this function. The first argument in both modes is +# the name of the Find-module where it is called (in original casing). +# +# The first simple mode looks like this: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( (DEFAULT_MSG|"Custom failure message") ... ) +# If the variables to are all valid, then _FOUND +# will be set to TRUE. +# If DEFAULT_MSG is given as second argument, then the function will generate +# itself useful success and error messages. You can also supply a custom error message +# for the failure case. This is not recommended. +# +# The second mode is more powerful and also supports version checking: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [FOUND_VAR ] +# [REQUIRED_VARS ...] +# [VERSION_VAR ] +# [HANDLE_COMPONENTS] +# [CONFIG_MODE] +# [FAIL_MESSAGE "Custom failure message"] ) +# +# In this mode, the name of the result-variable can be set either to either +# _FOUND or _FOUND using the FOUND_VAR option. +# Other names for the result-variable are not allowed. +# So for a Find-module named FindFooBar.cmake, the two possible names are +# FooBar_FOUND and FOOBAR_FOUND. It is recommended to use the original case version. +# If the FOUND_VAR option is not used, the default is _FOUND. +# +# As in the simple mode, if through are all valid, +# _FOUND will be set to TRUE. +# After REQUIRED_VARS the variables which are required for this package are listed. +# Following VERSION_VAR the name of the variable can be specified which holds +# the version of the package which has been found. If this is done, this version +# will be checked against the (potentially) specified required version used +# in the find_package() call. The EXACT keyword is also handled. The default +# messages include information about the required version and the version +# which has been actually found, both if the version is ok or not. +# If the package supports components, use the HANDLE_COMPONENTS option to enable +# handling them. In this case, find_package_handle_standard_args() will report +# which components have been found and which are missing, and the _FOUND +# variable will be set to FALSE if any of the required components (i.e. not the +# ones listed after OPTIONAL_COMPONENTS) are missing. +# Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for +# a find_package(... NO_MODULE) call. In this case VERSION_VAR will be set +# to _VERSION and the macro will automatically check whether the +# Config module was found. +# Via FAIL_MESSAGE a custom failure message can be specified, if this is not +# used, the default message will be displayed. +# +# Example for mode 1: +# +# find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) +# +# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and +# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. +# If it is not found and REQUIRED was used, it fails with FATAL_ERROR, +# independent whether QUIET was used or not. +# If it is found, success will be reported, including the content of . +# On repeated Cmake runs, the same message won't be printed again. +# +# Example for mode 2: +# +# find_package_handle_standard_args(LibXslt FOUND_VAR LibXslt_FOUND +# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS +# VERSION_VAR LibXslt_VERSION_STRING) +# In this case, LibXslt is considered to be found if the variable(s) listed +# after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and LibXslt_INCLUDE_DIRS +# in this case. The result will then be stored in LibXslt_FOUND . +# Also the version of LibXslt will be checked by using the version contained +# in LibXslt_VERSION_STRING. +# Since no FAIL_MESSAGE is given, the default messages will be printed. +# +# Another example for mode 2: +# +# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) +# find_package_handle_standard_args(Automoc4 CONFIG_MODE) +# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4 NO_MODULE) +# and adds an additional search directory for automoc4. +# Here the result will be stored in AUTOMOC4_FOUND. +# The following FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper +# success/error message. + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) + +# internal helper macro +macro(_FPHSA_FAILURE_MESSAGE _msg) + if (${_NAME}_FIND_REQUIRED) + message(FATAL_ERROR "${_msg}") + else () + if (NOT ${_NAME}_FIND_QUIETLY) + message(STATUS "${_msg}") + endif () + endif () +endmacro() + + +# internal helper macro to generate the failure message when used in CONFIG_MODE: +macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: + if(${_NAME}_CONFIG) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") + else() + # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. + # List them all in the error message: + if(${_NAME}_CONSIDERED_CONFIGS) + set(configsText "") + list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) + math(EXPR configsCount "${configsCount} - 1") + foreach(currentConfigIndex RANGE ${configsCount}) + list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) + list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) + set(configsText "${configsText} ${filename} (version ${version})\n") + endforeach() + if (${_NAME}_NOT_FOUND_MESSAGE) + set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") + endif() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") + + else() + # Simple case: No Config-file was found at all: + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") + endif() + endif() +endmacro() + + +function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) + +# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in +# new extended or in the "old" mode: + set(options CONFIG_MODE HANDLE_COMPONENTS) + set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) + set(multiValueArgs REQUIRED_VARS) + set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) + list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + + if(${INDEX} EQUAL -1) + set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) + set(FPHSA_REQUIRED_VARS ${ARGN}) + set(FPHSA_VERSION_VAR) + else() + + CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) + + if(FPHSA_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") + endif() + + if(NOT FPHSA_FAIL_MESSAGE) + set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") + endif() + endif() + +# now that we collected all arguments, process them + + if("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") + endif() + + # In config-mode, we rely on the variable _CONFIG, which is set by find_package() + # when it successfully found the config-file, including version checking: + if(FPHSA_CONFIG_MODE) + list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) + list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) + set(FPHSA_VERSION_VAR ${_NAME}_VERSION) + endif() + + if(NOT FPHSA_REQUIRED_VARS) + message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") + endif() + + list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + + string(TOUPPER ${_NAME} _NAME_UPPER) + string(TOLOWER ${_NAME} _NAME_LOWER) + + if(FPHSA_FOUND_VAR) + if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") + set(_FOUND_VAR ${FPHSA_FOUND_VAR}) + else() + message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") + endif() + else() + set(_FOUND_VAR ${_NAME_UPPER}_FOUND) + endif() + + # collect all variables which were not found, so they can be printed, so the + # user knows better what went wrong (#6375) + set(MISSING_VARS "") + set(DETAILS "") + # check if all passed variables are valid + unset(${_FOUND_VAR}) + foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) + if(NOT ${_CURRENT_VAR}) + set(${_FOUND_VAR} FALSE) + set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") + else() + set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") + endif() + endforeach() + if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE") + set(${_FOUND_VAR} TRUE) + endif() + + # component handling + unset(FOUND_COMPONENTS_MSG) + unset(MISSING_COMPONENTS_MSG) + + if(FPHSA_HANDLE_COMPONENTS) + foreach(comp ${${_NAME}_FIND_COMPONENTS}) + if(${_NAME}_${comp}_FOUND) + + if(NOT DEFINED FOUND_COMPONENTS_MSG) + set(FOUND_COMPONENTS_MSG "found components: ") + endif() + set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}") + + else() + + if(NOT DEFINED MISSING_COMPONENTS_MSG) + set(MISSING_COMPONENTS_MSG "missing components: ") + endif() + set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}") + + if(${_NAME}_FIND_REQUIRED_${comp}) + set(${_FOUND_VAR} FALSE) + set(MISSING_VARS "${MISSING_VARS} ${comp}") + endif() + + endif() + endforeach() + set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") + set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]") + endif() + + # version handling: + set(VERSION_MSG "") + set(VERSION_OK TRUE) + set(VERSION ${${FPHSA_VERSION_VAR}} ) + if (${_NAME}_FIND_VERSION) + + if(VERSION) + + if(${_NAME}_FIND_VERSION_EXACT) # exact version required + if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + set(VERSION_OK FALSE) + else () + set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") + endif () + + else() # minimum version specified: + if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") + set(VERSION_OK FALSE) + else () + set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") + endif () + endif() + + else() + + # if the package was not found, but a version was given, add that to the output: + if(${_NAME}_FIND_VERSION_EXACT) + set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + else() + set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + endif() + + endif() + else () + if(VERSION) + set(VERSION_MSG "(found version \"${VERSION}\")") + endif() + endif () + + if(VERSION_OK) + set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") + else() + set(${_FOUND_VAR} FALSE) + endif() + + + # print the result: + if (${_FOUND_VAR}) + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") + else () + + if(FPHSA_CONFIG_MODE) + _FPHSA_HANDLE_FAILURE_CONFIG_MODE() + else() + if(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + else() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + endif() + endif() + + endif () + + set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE) + +endfunction() diff --git a/upEngine/CMake/FindPackageMessage.cmake b/upEngine/CMake/FindPackageMessage.cmake new file mode 100644 index 0000000..5cea43e --- /dev/null +++ b/upEngine/CMake/FindPackageMessage.cmake @@ -0,0 +1,49 @@ +# FIND_PACKAGE_MESSAGE( "message for user" "find result details") +# +# This macro is intended to be used in FindXXX.cmake modules files. +# It will print a message once for each unique find result. +# This is useful for telling the user where a package was found. +# The first argument specifies the name (XXX) of the package. +# The second argument specifies the message to display. +# The third argument lists details about the find result so that +# if they change the message will be displayed again. +# The macro also obeys the QUIET argument to the find_package command. +# +# Example: +# +# if(X11_FOUND) +# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" +# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") +# else() +# ... +# endif() + +#============================================================================= +# Copyright 2008-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function(FIND_PACKAGE_MESSAGE pkg msg details) + # Avoid printing a message repeatedly for the same find result. + if(NOT ${pkg}_FIND_QUIETLY) + string(REGEX REPLACE "[\n]" "" details "${details}") + set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) + if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") + # The message has not yet been printed. + message(STATUS "${msg}") + + # Save the find details in the cache to avoid printing the same + # message again. + set("${DETAILS_VAR}" "${details}" + CACHE INTERNAL "Details about finding ${pkg}") + endif() + endif() +endfunction() diff --git a/upEngine/CMake/FindPkgMacros.cmake b/upEngine/CMake/FindPkgMacros.cmake new file mode 100644 index 0000000..5968623 --- /dev/null +++ b/upEngine/CMake/FindPkgMacros.cmake @@ -0,0 +1,163 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +################################################################## +# Provides some common functionality for the FindPackage modules +################################################################## + +# Begin processing of package +macro(findpkg_begin PREFIX) + if (NOT ${PREFIX}_FIND_QUIETLY) + message(STATUS "Looking for ${PREFIX}...") + endif () +endmacro(findpkg_begin) + +# Display a status message unless FIND_QUIETLY is set +macro(pkg_message PREFIX) + if (NOT ${PREFIX}_FIND_QUIETLY) + message(STATUS ${ARGN}) + endif () +endmacro(pkg_message) + +# Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes +macro(getenv_path VAR) + set(ENV_${VAR} $ENV{${VAR}}) + # replace won't work if var is blank + if (ENV_${VAR}) + string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} ) + endif () +endmacro(getenv_path) + +# Construct search paths for includes and libraries from a PREFIX_PATH +macro(create_search_paths PREFIX) + foreach(dir ${${PREFIX}_PREFIX_PATH}) + set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH} + ${dir}/include ${dir}/Include ${dir}/include/${PREFIX} ${dir}/Headers) + set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH} + ${dir}/lib ${dir}/Lib ${dir}/lib/${PREFIX} ${dir}/Libs) + set(${PREFIX}_BIN_SEARCH_PATH ${${PREFIX}_BIN_SEARCH_PATH} + ${dir}/bin) + endforeach(dir) + if(ANDROID) + set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH} ${OGRE_DEPENDENCIES_DIR}/lib/${ANDROID_ABI}) + endif() + set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH}) +endmacro(create_search_paths) + +# clear cache variables if a certain variable changed +macro(clear_if_changed TESTVAR) + # test against internal check variable + # HACK: Apparently, adding a variable to the cache cleans up the list + # a bit. We need to also remove any empty strings from the list, but + # at the same time ensure that we are actually dealing with a list. + list(APPEND ${TESTVAR} "") + list(REMOVE_ITEM ${TESTVAR} "") + if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}") + message(STATUS "${TESTVAR} changed.") + foreach(var ${ARGN}) + set(${var} "NOTFOUND" CACHE STRING "x" FORCE) + endforeach(var) + endif () + set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "x" FORCE) +endmacro(clear_if_changed) + +# Try to get some hints from pkg-config, if available +macro(use_pkgconfig PREFIX PKGNAME) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(${PREFIX} ${PKGNAME}) + endif () +endmacro (use_pkgconfig) + +# Couple a set of release AND debug libraries (or frameworks) +macro(make_library_set PREFIX) + if (${PREFIX}_FWK) + set(${PREFIX} ${${PREFIX}_FWK}) + elseif (${PREFIX}_REL AND ${PREFIX}_DBG) + set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG}) + elseif (${PREFIX}_REL) + set(${PREFIX} ${${PREFIX}_REL}) + elseif (${PREFIX}_DBG) + set(${PREFIX} ${${PREFIX}_DBG}) + endif () +endmacro(make_library_set) + +# Generate debug names from given release names +macro(get_debug_names PREFIX) + foreach(i ${${PREFIX}}) + set(${PREFIX}_DBG ${${PREFIX}_DBG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i}) + endforeach(i) +endmacro(get_debug_names) + +# Add the parent dir from DIR to VAR +macro(add_parent_dir VAR DIR) + get_filename_component(${DIR}_TEMP "${${DIR}}/.." ABSOLUTE) + set(${VAR} ${${VAR}} ${${DIR}_TEMP}) +endmacro(add_parent_dir) + +# Do the final processing for the package find. +macro(findpkg_finish PREFIX) + # skip if already processed during this run + if (NOT ${PREFIX}_FOUND) + if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY) + set(${PREFIX}_FOUND TRUE) + set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR}) + set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY}) + if (NOT ${PREFIX}_FIND_QUIETLY) + message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}") + endif () + else () + if (NOT ${PREFIX}_FIND_QUIETLY) + message(STATUS "Could not locate ${PREFIX}") + endif () + if (${PREFIX}_FIND_REQUIRED) + message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.") + endif () + endif () + + mark_as_advanced(${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK) + endif () +endmacro(findpkg_finish) + + +# Slightly customised framework finder +macro(findpkg_framework fwk) + if(APPLE) + set(${fwk}_FRAMEWORK_PATH + ${${fwk}_FRAMEWORK_SEARCH_PATH} + ${CMAKE_FRAMEWORK_PATH} + ~/Library/Frameworks + /Library/Frameworks + /System/Library/Frameworks + /Network/Library/Frameworks + ${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/Release + ${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/Debug + ) + # These could be arrays of paths, add each individually to the search paths + foreach(i ${OGRE_PREFIX_PATH}) + set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/macosx/Release ${i}/lib/macosx/Debug) + endforeach(i) + + foreach(i ${OGRE_PREFIX_BUILD}) + set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/macosx/Release ${i}/lib/macosx/Debug) + endforeach(i) + + foreach(dir ${${fwk}_FRAMEWORK_PATH}) + set(fwkpath ${dir}/${fwk}.framework) + if(EXISTS ${fwkpath}) + set(${fwk}_FRAMEWORK_INCLUDES ${${fwk}_FRAMEWORK_INCLUDES} + ${fwkpath}/Headers ${fwkpath}/PrivateHeaders) + set(${fwk}_FRAMEWORK_PATH ${dir}) + if (NOT ${fwk}_LIBRARY_FWK) + set(${fwk}_LIBRARY_FWK "-framework ${fwk}") + endif () + endif(EXISTS ${fwkpath}) + endforeach(dir) + endif(APPLE) +endmacro(findpkg_framework) diff --git a/upEngine/CMake/assimp-config-version.cmake b/upEngine/CMake/assimp-config-version.cmake new file mode 100644 index 0000000..53d187b --- /dev/null +++ b/upEngine/CMake/assimp-config-version.cmake @@ -0,0 +1,12 @@ +set( PACKAGE_VERSION "3.0.1264" ) +if( "${PACKAGE_FIND_VERSION}" VERSION_EQUAL "3.0.1264") + set(PACKAGE_VERSION_EXACT 1) +endif() +if( "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}" EQUAL "3" ) + set(PACKAGE_VERSION_COMPATIBLE 1) +elseif( "${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "3" ) + # for now backward compatible if minor version is less + if( ${PACKAGE_FIND_VERSION_MINOR} LESS 0 ) + set(PACKAGE_VERSION_COMPATIBLE 1) + endif() +endif() diff --git a/upEngine/CMake/assimp-config.cmake b/upEngine/CMake/assimp-config.cmake new file mode 100644 index 0000000..af5443b --- /dev/null +++ b/upEngine/CMake/assimp-config.cmake @@ -0,0 +1,74 @@ +# - Find Assimp Installation +# +# Users can set the following variables before calling the module: +# ASSIMP_DIR - The preferred installation prefix for searching for ASSIMP. Set by the user. +# +# ASSIMP_ROOT_DIR - the root directory where the installation can be found +# ASSIMP_CXX_FLAGS - extra flags for compilation +# ASSIMP_LINK_FLAGS - extra flags for linking +# ASSIMP_INCLUDE_DIRS - include directories +# ASSIMP_LIBRARY_DIRS - link directories +# ASSIMP_LIBRARIES - libraries to link plugins with +# ASSIMP_Boost_VERSION - the boost version assimp was compiled with +get_filename_component(_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_PREFIX "${_PREFIX}" PATH) +get_filename_component(_PREFIX "${_PREFIX}" PATH) +get_filename_component(ASSIMP_ROOT_DIR "${_PREFIX}" PATH) + +if( MSVC ) + # in order to prevent DLL hell, each of the DLLs have to be suffixed with the major version and msvc prefix + if( MSVC70 OR MSVC71 ) + set(MSVC_PREFIX "vc70") + elseif( MSVC80 ) + set(MSVC_PREFIX "vc80") + elseif( MSVC90 ) + set(MSVC_PREFIX "vc90") + else() + set(MSVC_PREFIX "vc100") + endif() + set(ASSIMP_LIBRARY_SUFFIX "-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" FORCE) +else() + set(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "the suffix for the openrave libraries" FORCE) +endif() + +set( ASSIMP_CXX_FLAGS ) # dynamically linked library +if( WIN32 ) + # for visual studio linking, most of the time boost dlls will be used + set( ASSIMP_CXX_FLAGS " -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB") +endif() +set( ASSIMP_LINK_FLAGS "" ) +set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/lib") +set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/include") +set( ASSIMP_LIBRARIES assimp${ASSIMP_LIBRARY_SUFFIX}) + +# the boost version assimp was compiled with +set( ASSIMP_Boost_VERSION ".") + +if( WIN32 ) + # search for the boost version assimp was compiled with + set(Boost_USE_MULTITHREAD ON) + set(Boost_USE_STATIC_LIBS OFF) + set(Boost_USE_STATIC_RUNTIME OFF) + find_package(Boost ${ASSIMP_Boost_VERSION} EXACT COMPONENTS thread date_time) + if(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") + set( ASSIMP_INCLUDE_DIRS "${ASSIMP_INCLUDE_DIRS}" ${Boost_INCLUDE_DIRS}) + else(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") + message(WARNING "Failed to find Boost ${ASSIMP_Boost_VERSION} necessary for assimp") + endif(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") +endif( WIN32 ) + +# for compatibility wiht pkg-config +set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}") +set(ASSIMP_LDFLAGS_OTHER "${ASSIMP_LINK_FLAGS}") + +MARK_AS_ADVANCED( + ASSIMP_ROOT_DIR + ASSIMP_CXX_FLAGS + ASSIMP_LINK_FLAGS + ASSIMP_INCLUDE_DIRS + ASSIMP_LIBRARIES + ASSIMP_Boost_VERSION + ASSIMP_CFLAGS_OTHER + ASSIMP_LDFLAGS_OTHER + ASSIMP_LIBRARY_SUFFIX +) diff --git a/upEngine/CMake/glfwConfig.cmake b/upEngine/CMake/glfwConfig.cmake new file mode 100644 index 0000000..b71d307 --- /dev/null +++ b/upEngine/CMake/glfwConfig.cmake @@ -0,0 +1,10 @@ +# - Config file for the glfw package +# It defines the following variables +# GLFW_INCLUDE_DIR, the path where GLFW headers are located +# GLFW_LIBRARY_DIR, folder in which the GLFW library is located +# GLFW_LIBRARY, library to link against to use GLFW + +set(GLFW_INCLUDE_DIR "/usr/include") +set(GLFW_LIBRARY_DIR "/usr/lib") + +find_library(GLFW_LIBRARY "glfw" HINTS ${GLFW_LIBRARY_DIR}) diff --git a/upEngine/CMake/glfwConfigVersion.cmake b/upEngine/CMake/glfwConfigVersion.cmake new file mode 100644 index 0000000..3b83630 --- /dev/null +++ b/upEngine/CMake/glfwConfigVersion.cmake @@ -0,0 +1,12 @@ + +set(PACKAGE_VERSION "3.0.1") + +if ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "3") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 0) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) +endif() + diff --git a/upEngine/CMake/glfwTargets-noconfig.cmake b/upEngine/CMake/glfwTargets-noconfig.cmake new file mode 100644 index 0000000..b9a995d --- /dev/null +++ b/upEngine/CMake/glfwTargets-noconfig.cmake @@ -0,0 +1,20 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "glfw" for configuration "" +set_property(TARGET glfw APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(glfw PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG "" + IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/lib/libglfw.so.3.0" + IMPORTED_SONAME_NOCONFIG "libglfw.so.3" + ) + +list(APPEND _IMPORT_CHECK_TARGETS glfw ) +list(APPEND _IMPORT_CHECK_FILES_FOR_glfw "${_IMPORT_PREFIX}/lib/libglfw.so.3.0" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/upEngine/CMake/glfwTargets.cmake b/upEngine/CMake/glfwTargets.cmake new file mode 100644 index 0000000..e6c21aa --- /dev/null +++ b/upEngine/CMake/glfwTargets.cmake @@ -0,0 +1,92 @@ +# Generated by CMake 2.8.11.1 + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget glfw) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +# Use original install prefix when loaded through a +# cross-prefix symbolic link such as /lib -> /usr/lib. +get_filename_component(_realCurr "${_IMPORT_PREFIX}" REALPATH) +get_filename_component(_realOrig "/usr/lib/cmake/glfw" REALPATH) +if(_realCurr STREQUAL _realOrig) + set(_IMPORT_PREFIX "/usr/lib/cmake/glfw") +endif() +unset(_realOrig) +unset(_realCurr) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) + +# Create imported target glfw +add_library(glfw SHARED IMPORTED) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/glfwTargets-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/upEngine/CMakeLists.txt b/upEngine/CMakeLists.txt new file mode 100644 index 0000000..0158315 --- /dev/null +++ b/upEngine/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 2.6) +project(upEngine) + +set(BUILD_EXTRA_WARNINGS "Warn" CACHE STRING "Set to Warn (default) or Warn-more to get additional compiler warnings") + +if(CMAKE_COMPILER_IS_GNUCXX) + include(CheckCXXCompilerFlag) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic") + #FIXME: take out -fpermissive when fixed in code + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") + + set(COLOR_DIAG_FLAG "-fcolor-diagnostics") + check_cxx_compiler_flag (${COLOR_DIAG_FLAG} HAVE_COLOR_DIAG_FLAG) + if(HAVE_COLOR_DIAG_FLAG) + message ("forcing colored compiler output") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COLOR_DIAG_FLAG}") + endif() + + set(WARN_EVERYTHING_FLAG "-Weverything") + # Some warnings that are of absolutely no interest + set(WARN_NOT_FLAGS "c++98-compat" "c++98-compat-pedantic" "exit-time-destructors") + if(${BUILD_EXTRA_WARNINGS} STREQUAL "Warn-more") + set(BUILD_EXTRA_WARNINGS "Warn") + else() + # These warnings are often meaningless + list(APPEND WARN_NOT_FLAGS "padded") + endif() + + check_cxx_compiler_flag (${WARN_EVERYTHING_FLAG} HAVE_WARN_EVERYTHING_FLAG) + if ((${BUILD_EXTRA_WARNINGS} STREQUAL "Warn") AND (HAVE_WARN_EVERYTHING_FLAG)) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARN_EVERYTHING_FLAG}") + endif() + + foreach(WARN_FLAG ${WARN_NOT_FLAGS}) + string(REPLACE "+" "x" TEST_FLAG "TEST_W${WARN_FLAG}") + check_cxx_compiler_flag ("-W${WARN_FLAG}" ${TEST_FLAG}) + if(${TEST_FLAG}) + message("disabling -W${WARN_FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-${WARN_FLAG}") + endif() + endforeach() +elseif(MSVC) + #FIXME: this is a guess + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") +endif() + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") + +find_package(assimp REQUIRED) +find_package(FreeImage REQUIRED) +find_package(Freetype REQUIRED) +find_package(GLEW REQUIRED) +find_package(glfw REQUIRED) +find_package(OpenGL REQUIRED) +add_definitions(${ASSIMP_DEFINITIONS} ${FreeImage_DEFINITIONS} ${FREETYPE_DEFINITIONS} ${GLEW_DEFINITIONS} ${GLFW_DEFINITIONS} ${OPENGL_DEFINITIONS}) +include_directories(${ASSIMP_INCLUDE_DIRS} ${FreeImage_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS} ${GLFW_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS}) +link_directories(${ASSIMP_LIBRARY_DIRS} ${FreeImage_LIBRARY_DIRS} ${FREETYPE_LIBRARY_DIRS} ${GLEW_LIBRARY_DIRS} ${GLFW_LIBRARY_DIRS} ${OPENGL_LIBRARY_DIRS}) + +include_directories(.) + +add_executable(upEngine + AssetManager.cpp + Camera.cpp + FreeTypeFont.cpp + main.cpp + Mesh.cpp + Shader.cpp + ShaderManager.cpp + Skybox.cpp + Terrain.cpp + Texture.cpp + VBO.cpp + ) +target_link_libraries(upEngine ${ASSIMP_LIBRARIES} ${FreeImage_LIBRARY} ${FREETYPE_LIBRARIES} ${GLEW_LIBRARIES} ${GLFW_LIBRARY} ${OPENGL_LIBRARIES}) diff --git a/upEngine/Camera.h b/upEngine/Camera.h index 697e909..21406f4 100644 --- a/upEngine/Camera.h +++ b/upEngine/Camera.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "Utils.h" diff --git a/upEngine/Shader.cpp b/upEngine/Shader.cpp index 7b3b77a..cbed96e 100644 --- a/upEngine/Shader.cpp +++ b/upEngine/Shader.cpp @@ -45,7 +45,8 @@ bool Shader::loadSource( const char* p_cPath, unsigned int uiType ) long int size; char* content; - fopen_s( &file, p_cPath, "r" ); + //fopen_s( &file, p_cPath, "r" ); + file = fopen( p_cPath, "r" ); if( file == NULL ) return NULL; diff --git a/upEngine/Terrain.cpp b/upEngine/Terrain.cpp index a12983f..7326fc3 100644 --- a/upEngine/Terrain.cpp +++ b/upEngine/Terrain.cpp @@ -12,10 +12,10 @@ Terrain::~Terrain() void Terrain::loadHeightMap( std::string sPath ) { - int width, height, channels; - BYTE* bDataPointer = SOIL_load_image( Utils::contentPath( sPath ).c_str(), &width, &height, &channels, SOIL_LOAD_RGB ); + //int width, height, channels; + //BYTE* bDataPointer = SOIL_load_image( Utils::contentPath( sPath ).c_str(), &width, &height, &channels, SOIL_LOAD_RGB ); - /*FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; FIBITMAP* dib(0); fif = FreeImage_GetFileType( Utils::contentPath( sPath ).c_str(), 0 ); @@ -45,7 +45,7 @@ void Terrain::loadHeightMap( std::string sPath ) return; } - int width = FreeImage_GetWidth( dib ), height = FreeImage_GetHeight( dib );*/ + int width = FreeImage_GetWidth( dib ), height = FreeImage_GetHeight( dib ); //Create terrain data float* p_fData = new float[ width * height * 3 ]; diff --git a/upEngine/Terrain.h b/upEngine/Terrain.h index 0239a92..a04fe44 100644 --- a/upEngine/Terrain.h +++ b/upEngine/Terrain.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/upEngine/Texture.cpp b/upEngine/Texture.cpp index 80415c3..d175039 100644 --- a/upEngine/Texture.cpp +++ b/upEngine/Texture.cpp @@ -59,7 +59,7 @@ void Texture::loadFile( std::string sPath ) if( fif == FIF_UNKNOWN ) { - printf( "ERROR! Failed to figure out filetype of file: '%s' \n", sPath ); + printf( "ERROR! Failed to figure out filetype of file: '%s' \n", sPath.c_str() ); return; } @@ -67,7 +67,7 @@ void Texture::loadFile( std::string sPath ) dib = FreeImage_Load( fif, Utils::contentPath( sPath ).c_str() ); else { - printf( "ERROR! Failed to load image file: '%s' \n", sPath ); + printf( "ERROR! Failed to load image file: '%s' \n", sPath.c_str() ); return; } @@ -83,7 +83,7 @@ void Texture::loadFile( std::string sPath ) if( _pData == NULL || _iWidth == 0 || _iHeight == 0 ) { - printf( "ERROR! Failed to load image file: '%s' \n", sPath ); + printf( "ERROR! Failed to load image file: '%s' \n", sPath.c_str() ); return; } diff --git a/upEngine/Texture.h b/upEngine/Texture.h index be19750..44897fa 100644 --- a/upEngine/Texture.h +++ b/upEngine/Texture.h @@ -1,8 +1,8 @@ #pragma once #include -//#include -#include +//#include +#include #include #include "Utils.h" diff --git a/upEngine/Utils.h b/upEngine/Utils.h index 4957416..cbb3957 100644 --- a/upEngine/Utils.h +++ b/upEngine/Utils.h @@ -3,7 +3,11 @@ #define PI 3.14159265 typedef unsigned char BYTE; +#ifdef _WIN32 #include +#else +#include +#endif #include #include #include diff --git a/upEngine/main.cpp b/upEngine/main.cpp index 303a6d8..d393228 100644 --- a/upEngine/main.cpp +++ b/upEngine/main.cpp @@ -12,8 +12,8 @@ #include #include -#include -#include +#include +#include #include #include