diff --git a/code/CMakeModules/AndroidToolChain.cmake b/code/CMakeModules/AndroidToolChain.cmake new file mode 100644 index 000000000..049c39adf --- /dev/null +++ b/code/CMakeModules/AndroidToolChain.cmake @@ -0,0 +1,149 @@ +IF(DEFINED CMAKE_CROSSCOMPILING) + # subsequent toolchain loading is not really needed + RETURN() +ENDIF() + +# Standard settings +SET(CMAKE_SYSTEM_NAME Linux) +SET(CMAKE_SYSTEM_VERSION 1) # TODO: determine target Linux version +SET(UNIX ON) +SET(LINUX ON) +SET(ANDROID ON) + +IF(NOT NDK_ROOT) + SET(NDK_ROOT $ENV{NDK_ROOT}) + + IF(CMAKE_HOST_WIN32) + FILE(TO_CMAKE_PATH ${NDK_ROOT} NDK_ROOT) + ENDIF(CMAKE_HOST_WIN32) +ENDIF(NOT NDK_ROOT) + +IF(NOT TARGET_CPU) + SET(TARGET_CPU "armv7") +ENDIF(NOT TARGET_CPU) + +IF(TARGET_CPU STREQUAL "armv7") + SET(LIBRARY_ARCHITECTURE "armeabi-v7a") + SET(CMAKE_SYSTEM_PROCESSOR "armv7") + SET(TOOLCHAIN_ARCH "arm") + SET(TOOLCHAIN_PREFIX "arm-linux-androideabi") + SET(TOOLCHAIN_BIN_PREFIX "arm") + SET(MINIMUM_NDK_TARGET 4) +ELSEIF(TARGET_CPU STREQUAL "armv5") + SET(LIBRARY_ARCHITECTURE "armeabi") + SET(CMAKE_SYSTEM_PROCESSOR "armv5") + SET(TOOLCHAIN_ARCH "arm") + SET(TOOLCHAIN_PREFIX "arm-linux-androideabi") + SET(TOOLCHAIN_BIN_PREFIX "arm") + SET(MINIMUM_NDK_TARGET 4) +ELSEIF(TARGET_CPU STREQUAL "x86") + SET(LIBRARY_ARCHITECTURE "x86") + SET(CMAKE_SYSTEM_PROCESSOR "x86") + SET(TOOLCHAIN_ARCH "x86") + SET(TOOLCHAIN_PREFIX "x86") + SET(TOOLCHAIN_BIN_PREFIX "i686") + SET(MINIMUM_NDK_TARGET 9) +ELSEIF(TARGET_CPU STREQUAL "mips") + SET(LIBRARY_ARCHITECTURE "mips") + SET(CMAKE_SYSTEM_PROCESSOR "mips") + SET(TOOLCHAIN_ARCH "mips") + SET(TOOLCHAIN_PREFIX "mipsel-linux-android") + SET(TOOLCHAIN_BIN_PREFIX "mipsel") + SET(MINIMUM_NDK_TARGET 9) +ENDIF(TARGET_CPU STREQUAL "armv7") + +IF(NOT NDK_TARGET) + SET(NDK_TARGET ${MINIMUM_NDK_TARGET}) +ENDIF(NOT NDK_TARGET) + +FILE(GLOB _TOOLCHAIN_VERSIONS "${NDK_ROOT}/toolchains/${TOOLCHAIN_PREFIX}-*") +IF(_TOOLCHAIN_VERSIONS) + LIST(SORT _TOOLCHAIN_VERSIONS) + LIST(REVERSE _TOOLCHAIN_VERSIONS) + FOREACH(_TOOLCHAIN_VERSION ${_TOOLCHAIN_VERSIONS}) + STRING(REGEX REPLACE ".+${TOOLCHAIN_PREFIX}-([0-9.]+)" "\\1" _TOOLCHAIN_VERSION "${_TOOLCHAIN_VERSION}") + IF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$") + LIST(APPEND NDK_TOOLCHAIN_VERSIONS ${_TOOLCHAIN_VERSION}) + ENDIF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$") + ENDFOREACH(_TOOLCHAIN_VERSION) +ENDIF(_TOOLCHAIN_VERSIONS) + +IF(NOT NDK_TOOLCHAIN_VERSIONS) + MESSAGE(FATAL_ERROR "No Android toolchain found in default search path ${NDK_ROOT}/toolchains") +ENDIF(NOT NDK_TOOLCHAIN_VERSIONS) + +IF(NDK_TOOLCHAIN_VERSION) + LIST(FIND NDK_TOOLCHAIN_VERSIONS "${NDK_TOOLCHAIN_VERSION}" _INDEX) + IF(_INDEX EQUAL -1) + LIST(GET NDK_TOOLCHAIN_VERSIONS 0 NDK_TOOLCHAIN_VERSION) + ENDIF(_INDEX EQUAL -1) +ELSE(NDK_TOOLCHAIN_VERSION) + LIST(GET NDK_TOOLCHAIN_VERSIONS 0 NDK_TOOLCHAIN_VERSION) +ENDIF(NDK_TOOLCHAIN_VERSION) + +MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${NDK_TOOLCHAIN_VERSION}") + +IF(CMAKE_HOST_WIN32) + SET(TOOLCHAIN_HOST "windows") + SET(TOOLCHAIN_BIN_SUFFIX ".exe") +ELSEIF(CMAKE_HOST_APPLE) + SET(TOOLCHAIN_HOST "apple") + SET(TOOLCHAIN_BIN_SUFFIX "") +ELSEIF(CMAKE_HOST_UNIX) + SET(TOOLCHAIN_HOST "linux") + SET(TOOLCHAIN_BIN_SUFFIX "") +ENDIF(CMAKE_HOST_WIN32) + +SET(TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${TOOLCHAIN_PREFIX}-${NDK_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}") +SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}") + +IF(NOT EXISTS "${TOOLCHAIN_ROOT}") + FILE(GLOB _TOOLCHAIN_PREFIXES "${TOOLCHAIN_ROOT}*") + IF(_TOOLCHAIN_PREFIXES) + LIST(GET _TOOLCHAIN_PREFIXES 0 TOOLCHAIN_ROOT) + ENDIF(_TOOLCHAIN_PREFIXES) +ENDIF(NOT EXISTS "${TOOLCHAIN_ROOT}") + +MESSAGE(STATUS "Found Android toolchain in ${TOOLCHAIN_ROOT}") +MESSAGE(STATUS "Found Android platform in ${PLATFORM_ROOT}") + +# include dirs +SET(PLATFORM_INCLUDE_DIR "${PLATFORM_ROOT}/usr/include") +SET(STL_DIR "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++") + +IF(EXISTS "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}") + # NDK version >= 8b + SET(STL_DIR "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}") +ENDIF(EXISTS "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}") + +# Determine bin prefix for toolchain +FILE(GLOB _TOOLCHAIN_BIN_PREFIXES "${TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-*-gcc${TOOLCHAIN_BIN_SUFFIX}") +IF(_TOOLCHAIN_BIN_PREFIXES) + LIST(GET _TOOLCHAIN_BIN_PREFIXES 0 _TOOLCHAIN_BIN_PREFIX) + STRING(REGEX REPLACE "${TOOLCHAIN_ROOT}/bin/([a-z0-9-]+)-gcc${TOOLCHAIN_BIN_SUFFIX}" "\\1" TOOLCHAIN_BIN_PREFIX "${_TOOLCHAIN_BIN_PREFIX}") +ENDIF(_TOOLCHAIN_BIN_PREFIXES) + +SET(STL_INCLUDE_DIR "${STL_DIR}/include") +SET(STL_LIBRARY_DIR "${STL_DIR}/libs/${LIBRARY_ARCHITECTURE}") +SET(STL_INCLUDE_CPU_DIR "${STL_LIBRARY_DIR}/include") +SET(STL_LIBRARY "${STL_LIBRARY_DIR}/libgnustl_static.a") + +SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_ROOT} ${PLATFORM_ROOT}/usr ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} $ENV{EXTERNAL_ANDROID_PATH} CACHE string "Android find search path root") + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +INCLUDE_DIRECTORIES(${STL_INCLUDE_DIR} ${STL_INCLUDE_CPU_DIR}) + +MACRO(SET_TOOLCHAIN_BINARY _NAME _BINARY) + SET(${_NAME} ${TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX}) +ENDMACRO(SET_TOOLCHAIN_BINARY) + +SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER gcc) +SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER g++) + +# Force the compilers to GCC for Android +include (CMakeForceCompiler) +CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} GNU) +CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} GNU) diff --git a/code/CMakeModules/FindCustomMFC.cmake b/code/CMakeModules/FindCustomMFC.cmake index 7dd87c15f..6f2f163d3 100644 --- a/code/CMakeModules/FindCustomMFC.cmake +++ b/code/CMakeModules/FindCustomMFC.cmake @@ -4,42 +4,35 @@ # MFC_LIBRARY_DIR, where to find libraries # MFC_INCLUDE_DIR, where to find headers +IF(CustomMFC_FIND_REQUIRED) + SET(MFC_FIND_REQUIRED TRUE) +ENDIF(CustomMFC_FIND_REQUIRED) + # Try to find MFC using official module, MFC_FOUND is set FIND_PACKAGE(MFC) -SET(CUSTOM_MFC_DIR FALSE) +IF(NOT MFC_DIR) + # If MFC have been found, remember their directory + IF(MFC_FOUND AND VC_DIR) + SET(MFC_STANDARD_DIR "${VC_DIR}/atlmfc") + ENDIF(MFC_FOUND AND VC_DIR) -# If using STLport and MFC have been found, remember its directory -IF(WITH_STLPORT AND MFC_FOUND AND VC_DIR) - SET(MFC_STANDARD_DIR "${VC_DIR}/atlmfc") -ENDIF(WITH_STLPORT AND MFC_FOUND AND VC_DIR) - -# If using STLport or MFC haven't been found, search for afxwin.h -IF(WITH_STLPORT OR NOT MFC_FOUND) FIND_PATH(MFC_DIR include/afxwin.h - PATHS + HINTS ${MFC_STANDARD_DIR} ) +ENDIF(NOT MFC_DIR) - IF(CustomMFC_FIND_REQUIRED) - SET(MFC_FIND_REQUIRED TRUE) - ENDIF(CustomMFC_FIND_REQUIRED) +# Display an error message if MFC are not found, MFC_FOUND is updated +# User will be able to update MFC_DIR to the correct directory +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MFC DEFAULT_MSG MFC_DIR) - # Display an error message if MFC are not found, MFC_FOUND is updated - # User will be able to update MFC_DIR to the correct directory - INCLUDE(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(MFC DEFAULT_MSG MFC_DIR) +IF(MFC_FOUND) + SET(MFC_INCLUDE_DIR "${MFC_DIR}/include") + INCLUDE_DIRECTORIES(${MFC_INCLUDE_DIR}) - IF(MFC_FOUND) - SET(CUSTOM_MFC_DIR TRUE) - SET(MFC_INCLUDE_DIR "${MFC_DIR}/include") - INCLUDE_DIRECTORIES(${MFC_INCLUDE_DIR}) - ENDIF(MFC_FOUND) -ENDIF(WITH_STLPORT OR NOT MFC_FOUND) - -# Only if using a custom path -IF(CUSTOM_MFC_DIR) # Using 32 or 64 bits libraries IF(TARGET_X64) SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64") @@ -49,9 +42,7 @@ IF(CUSTOM_MFC_DIR) # Add MFC libraries directory to default library path LINK_DIRECTORIES(${MFC_LIBRARY_DIR}) -ENDIF(CUSTOM_MFC_DIR) -IF(MFC_FOUND) # Set definitions for using MFC in DLL SET(MFC_DEFINITIONS -D_AFXDLL) ENDIF(MFC_FOUND) diff --git a/code/CMakeModules/FindMSVC.cmake b/code/CMakeModules/FindMSVC.cmake new file mode 100644 index 000000000..822e752dd --- /dev/null +++ b/code/CMakeModules/FindMSVC.cmake @@ -0,0 +1,76 @@ +# - Find MS Visual C++ +# +# VC_INCLUDE_DIR - where to find headers +# VC_INCLUDE_DIRS - where to find headers +# VC_LIBRARY_DIR - where to find libraries +# VC_FOUND - True if MSVC found. + +MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION) + # Software/Wow6432Node/... + GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;${_VERSION}]" ABSOLUTE) + + IF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry") + SET(VC${_VERSION}_DIR) + GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;${_VERSION}]" ABSOLUTE) + IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") + SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/") + ENDIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") + ENDIF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry") + + IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") + SET(VC${_VERSION}_FOUND ON) + IF(NOT MSVC_FIND_QUIETLY) + MESSAGE(STATUS "Found Visual C++ ${_VERSION} in ${VC${_VERSION}_DIR}") + ENDIF(NOT MSVC_FIND_QUIETLY) + ELSEIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") + SET(VC${_VERSION}_FOUND OFF) + SET(VC${_VERSION}_DIR "") + ENDIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") +ENDMACRO(DETECT_VC_VERSION_HELPER) + +MACRO(DETECT_VC_VERSION _VERSION) + SET(VC${_VERSION}_FOUND OFF) + DETECT_VC_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION}) + + IF(NOT VC${_VERSION}_FOUND) + DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION}) + ENDIF(NOT VC${_VERSION}_FOUND) + + IF(NOT VC${_VERSION}_FOUND) + SET(VC_FOUND ON) + SET(VC_DIR "${VC${_VERSION}_DIR}") + ENDIF(NOT VC${_VERSION}_FOUND) +ENDMACRO(DETECT_VC_VERSION) + +IF(MSVC11) + DETECT_VC_VERSION("11.0") + + IF(NOT MSVC11_REDIST_DIR) + # If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist + SET(MSVC11_REDIST_DIR "${EXTERNAL_PATH}/redist") + ENDIF(NOT MSVC11_REDIST_DIR) +ELSEIF(MSVC10) + DETECT_VC_VERSION("10.0") + + IF(NOT MSVC10_REDIST_DIR) + # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist + SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist") + ENDIF(NOT MSVC10_REDIST_DIR) +ELSEIF(MSVC90) + DETECT_VC_VERSION("9.0") +ELSEIF(MSVC80) + DETECT_VC_VERSION("8.0") +ENDIF(MSVC11) + +# If you plan to use VC++ compilers with WINE, set VC_DIR environment variable +IF(NOT VC_DIR) + SET(VC_DIR $ENV{VC_DIR}) +ENDIF(NOT VC_DIR) + +IF(NOT VC_DIR) + STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${CMAKE_CXX_COMPILER}) +ENDIF(NOT VC_DIR) + +SET(VC_INCLUDE_DIR "${VC_DIR}/include") +SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR}) diff --git a/code/CMakeModules/FindMercurial.cmake b/code/CMakeModules/FindMercurial.cmake index a18e50c43..b0602cbdf 100644 --- a/code/CMakeModules/FindMercurial.cmake +++ b/code/CMakeModules/FindMercurial.cmake @@ -48,7 +48,8 @@ # License text for the above reference.) FIND_PROGRAM(Mercurial_HG_EXECUTABLE hg - DOC "mercurial command line client") + DOC "mercurial command line client" + HINTS /opt/local/bin) MARK_AS_ADVANCED(Mercurial_HG_EXECUTABLE) IF(Mercurial_HG_EXECUTABLE) @@ -58,7 +59,7 @@ IF(Mercurial_HG_EXECUTABLE) STRING(REGEX REPLACE ".*version ([\\.0-9]+).*" "\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}") - + MACRO(Mercurial_WC_INFO dir prefix) EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip --template "{rev};{node};{tags};{author}" WORKING_DIRECTORY ${dir} diff --git a/code/CMakeModules/FindWindowsSDK.cmake b/code/CMakeModules/FindWindowsSDK.cmake index 9d9b91777..8f6ed5772 100644 --- a/code/CMakeModules/FindWindowsSDK.cmake +++ b/code/CMakeModules/FindWindowsSDK.cmake @@ -6,80 +6,160 @@ # WINSDK_LIBRARY_DIR - where to find libraries # WINSDK_FOUND - True if Windows SDK found. -IF(WINSDK_INCLUDE_DIR) - # Already in cache, be silent - SET(WindowsSDK_FIND_QUIETLY TRUE) -ENDIF(WINSDK_INCLUDE_DIR) +IF(WINSDK_FOUND) + # If Windows SDK already found, skip it + RETURN() +ENDIF(WINSDK_FOUND) -# TODO: add the possibility to use a specific Windows SDK +SET(WINSDK_VERSION "CURRENT" CACHE STRING "Windows SDK version to prefer") -IF(MSVC11) - GET_FILENAME_COMPONENT(WINSDK8_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE) - GET_FILENAME_COMPONENT(WINSDK8_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;ProductVersion]" NAME) +MACRO(DETECT_WINSDK_VERSION_HELPER _ROOT _VERSION) + GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};InstallationFolder]" ABSOLUTE) - IF(WINSDK8_DIR) + IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry") + SET(WINSDK${_VERSION}_FOUND ON) + GET_FILENAME_COMPONENT(WINSDK${_VERSION}_VERSION_FULL "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};ProductVersion]" NAME) IF(NOT WindowsSDK_FIND_QUIETLY) - MESSAGE(STATUS "Found Windows SDK ${WINSDK8_VERSION} in ${WINSDK8_DIR}") + MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}") ENDIF(NOT WindowsSDK_FIND_QUIETLY) - IF(TARGET_ARM) - SET(WINSDK8_SUFFIX "arm") - ELSEIF(TARGET_X64) - SET(WINSDK8_SUFFIX "x64") - ELSEIF(TARGET_X86) - SET(WINSDK8_SUFFIX "x86") - ENDIF(TARGET_ARM) - ENDIF(WINSDK8_DIR) -ENDIF(MSVC11) + ELSEIF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry") + SET(WINSDK${_VERSION}_DIR "") + ENDIF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry") +ENDMACRO(DETECT_WINSDK_VERSION_HELPER) -GET_FILENAME_COMPONENT(WINSDK71_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;InstallationFolder]" ABSOLUTE CACHE) -GET_FILENAME_COMPONENT(WINSDK71_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;ProductVersion]" NAME) +MACRO(DETECT_WINSDK_VERSION _VERSION) + SET(WINSDK${_VERSION}_FOUND OFF) + DETECT_WINSDK_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION}) + + IF(NOT WINSDK${_VERSION}_FOUND) + DETECT_WINSDK_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION}) + ENDIF(NOT WINSDK${_VERSION}_FOUND) +ENDMACRO(DETECT_WINSDK_VERSION) -IF(WINSDK71_DIR) - IF(NOT WindowsSDK_FIND_QUIETLY) - MESSAGE(STATUS "Found Windows SDK ${WINSDK71_VERSION} in ${WINSDK71_DIR}") - ENDIF(NOT WindowsSDK_FIND_QUIETLY) -ENDIF(WINSDK71_DIR) +SET(WINSDK_VERSIONS "8.0" "8.0A" "7.1" "7.0A" "6.1" "6.0" "6.0A") + +# Search all supported Windows SDKs +FOREACH(_VERSION ${WINSDK_VERSIONS}) + DETECT_WINSDK_VERSION(${_VERSION}) +ENDFOREACH(_VERSION) + +IF(TARGET_ARM) + SET(WINSDK8_SUFFIX "arm") +ELSEIF(TARGET_X64) + SET(WINSDK8_SUFFIX "x64") +ELSEIF(TARGET_X86) + SET(WINSDK8_SUFFIX "x86") +ENDIF(TARGET_ARM) -GET_FILENAME_COMPONENT(WINSDKCURRENT_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE) GET_FILENAME_COMPONENT(WINSDKCURRENT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentVersion]" NAME) -IF(WINSDKCURRENT_DIR) +IF(WINSDKCURRENT_VERSION AND NOT WINSDKCURRENT_VERSION STREQUAL "/registry") IF(NOT WindowsSDK_FIND_QUIETLY) - MESSAGE(STATUS "Found Windows SDK ${WINSDKCURRENT_VERSION} in ${WINSDKCURRENT_DIR}") +# MESSAGE(STATUS "Current version is ${WINSDKCURRENT_VERSION}") ENDIF(NOT WindowsSDK_FIND_QUIETLY) -ENDIF(WINSDKCURRENT_DIR) +ENDIF(WINSDKCURRENT_VERSION AND NOT WINSDKCURRENT_VERSION STREQUAL "/registry") +SET(WINSDKENV_DIR $ENV{WINSDK_DIR}) + +MACRO(USE_CURRENT_WINSDK) + IF(WINSDKENV_DIR) + SET(WINSDK_VERSION "") + SET(WINSDK_VERSION_FULL "") + SET(WINSDK_DIR ${WINSDKENV_DIR}) + FOREACH(_VERSION ${WINSDK_VERSIONS}) + IF(WINSDK_DIR STREQUAL WINSDK${_VERSION}_DIR) + SET(WINSDK_VERSION ${_VERSION}) + SET(WINSDK_VERSION_FULL "${WINSDK${_VERSION}_VERSION_FULL}") + BREAK() + ENDIF(WINSDK_DIR STREQUAL WINSDK${_VERSION}_DIR) + ENDFOREACH(_VERSION) + ELSE(WINSDKENV_DIR) + # Windows SDK 7.0A doesn't provide 64bits compilers, use SDK 7.1 for 64 bits + IF(WINSDKCURRENT_VERSION STREQUAL WINSDK7.0A_VERSION_FULL) + IF(TARGET_X64) + SET(WINSDK_VERSION "7.1") + SET(WINSDK_VERSION_FULL ${WINSDK7.1_VERSION_FULL}) + SET(WINSDK_DIR ${WINSDK7.1_DIR}) + ELSE(TARGET_X64) + SET(WINSDK_VERSION "7.0A") + SET(WINSDK_VERSION_FULL ${WINSDK7.0A_VERSION_FULL}) + SET(WINSDK_DIR ${WINSDK7.0A_DIR}) + ENDIF(TARGET_X64) + ELSE(WINSDKCURRENT_VERSION STREQUAL WINSDK7.0A_VERSION_FULL) + FOREACH(_VERSION ${WINSDK_VERSIONS}) + IF(WINSDKCURRENT_VERSION STREQUAL WINSDK${_VERSION}_VERSION) + SET(WINSDK_VERSION ${_VERSION}) + SET(WINSDK_VERSION_FULL "${WINSDK${_VERSION}_VERSION_FULL}") + SET(WINSDK_DIR "${WINSDK${_VERSION}_DIR}") + BREAK() + ENDIF(WINSDKCURRENT_VERSION STREQUAL WINSDK${_VERSION}_VERSION) + ENDFOREACH(_VERSION) + ENDIF(WINSDKCURRENT_VERSION STREQUAL WINSDK7.0A_VERSION_FULL) + ENDIF(WINSDKENV_DIR) +ENDMACRO(USE_CURRENT_WINSDK) + +IF(WINSDK_VERSION STREQUAL "CURRENT") + USE_CURRENT_WINSDK() +ELSE(WINSDK_VERSION STREQUAL "CURRENT") + IF(WINSDK${WINSDK_VERSION}_FOUND) + SET(WINSDK_VERSION_FULL "${WINSDK${WINSDK_VERSION}_VERSION_FULL}") + SET(WINSDK_DIR "${WINSDK${WINSDK_VERSION}_DIR}") + ELSE(WINSDK${WINSDK_VERSION}_FOUND) + USE_CURRENT_WINSDK() + ENDIF(WINSDK${WINSDK_VERSION}_FOUND) +ENDIF(WINSDK_VERSION STREQUAL "CURRENT") + +IF(WINSDK_DIR) + MESSAGE(STATUS "Using Windows SDK ${WINSDK_VERSION}") +ELSE(WINSDK_DIR) + MESSAGE(FATAL_ERROR "Unable to find Windows SDK!") +ENDIF(WINSDK_DIR) + +# directory where Win32 headers are found FIND_PATH(WINSDK_INCLUDE_DIR Windows.h HINTS - ${WINSDK8_DIR}/Include/um - ${WINSDK71_DIR}/Include - ${WINSDKCURRENT_DIR}/Include + ${WINSDK_DIR}/Include/um + ${WINSDK_DIR}/Include ) +# directory where DirectX headers are found FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h HINTS - ${WINSDK8_DIR}/Include/shared - ${WINSDK71_DIR}/Include - ${WINSDKCURRENT_DIR}/Include + ${WINSDK_DIR}/Include/shared + ${WINSDK_DIR}/Include ) +# directory where all libraries are found FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib HINTS - ${WINSDK8_DIR}/Lib/win8/um/${WINSDK8_SUFFIX} - ${WINSDK71_DIR}/Lib - ${WINSDKCURRENT_DIR}/Lib + ${WINSDK_DIR}/Lib/win8/um/${WINSDK8_SUFFIX} + ${WINSDK_DIR}/Lib ) +# signtool is used to sign executables FIND_PROGRAM(WINSDK_SIGNTOOL signtool HINTS - ${WINSDK8_DIR}/Bin/x86 - ${WINSDK71_DIR}/Bin - ${WINSDKCURRENT_DIR}/Bin + ${WINSDK_DIR}/Bin/x86 + ${WINSDK_DIR}/Bin +) + +# midl is used to generate IDL interfaces +FIND_PROGRAM(WINSDK_MIDL midl + HINTS + ${WINSDK_DIR}/Bin/x86 + ${WINSDK_DIR}/Bin ) IF(WINSDK_INCLUDE_DIR) - SET(WINSDK_FOUND TRUE) + SET(WINSDK_FOUND ON) SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIR} ${WINSDK_SHARED_INCLUDE_DIR}) + SET(CMAKE_LIBRARY_PATH ${WINSDK_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH}) + INCLUDE_DIRECTORIES(${WINSDK_INCLUDE_DIRS}) + + # Fix for using Windows SDK 7.1 with Visual C++ 2012 + IF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11) + ADD_DEFINITIONS(-D_USING_V110_SDK71_) + ENDIF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11) ELSE(WINSDK_INCLUDE_DIR) IF(NOT WindowsSDK_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find Windows SDK!") diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index 18e997af2..21b234f74 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -19,6 +19,7 @@ IF(SOURCE_DIR) SET(SOURCE_DIR ${ROOT_DIR}) ENDIF(NOT SOURCE_DIR AND ROOT_DIR) ELSE(SOURCE_DIR) + SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}) SET(ROOT_DIR ${CMAKE_SOURCE_DIR}) ENDIF(SOURCE_DIR) @@ -57,6 +58,15 @@ IF(EXISTS "${ROOT_DIR}/.hg/") ENDIF(MERCURIAL_FOUND) ENDIF(EXISTS "${ROOT_DIR}/.hg/") +# if processing exported sources, use "revision" file if exists +IF(SOURCE_DIR AND NOT DEFINED REVISION) + SET(REVISION_FILE ${SOURCE_DIR}/revision) + IF(EXISTS ${REVISION_FILE}) + FILE(STRINGS ${REVISION_FILE} REVISION LIMIT_COUNT 1) + MESSAGE(STATUS "Read revision ${REVISION} from file") + ENDIF(EXISTS ${REVISION_FILE}) +ENDIF(SOURCE_DIR AND NOT DEFINED REVISION) + IF(SOURCE_DIR AND DEFINED REVISION) IF(EXISTS ${SOURCE_DIR}/revision.h.in) MESSAGE(STATUS "Revision: ${REVISION}") diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index da26978c5..9033f6583 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -38,17 +38,16 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD) LIST(APPEND _FLAGS " ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}}") - IF(NOT MSVC) - GET_TARGET_PROPERTY(_targetType ${_target} TYPE) - IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) - LIST(APPEND _FLAGS " -fPIC") - ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) + GET_TARGET_PROPERTY(_targetType ${_target} TYPE) + IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) + LIST(APPEND _FLAGS " ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") + ELSE(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE) IF(_pic) - LIST(APPEND _FLAGS " -fPIE") + LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}") ENDIF(_pic) - ENDIF(NOT MSVC) + ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES) FOREACH(item ${DIRINC}) diff --git a/code/CMakeModules/iOSToolChain.cmake b/code/CMakeModules/iOSToolChain.cmake new file mode 100644 index 000000000..5b419778e --- /dev/null +++ b/code/CMakeModules/iOSToolChain.cmake @@ -0,0 +1,183 @@ +# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake +# files which are included with CMake 2.8.4 +# It has been altered for iOS development +# +# Options: +# +# IOS_VERSION = last(default) or specific one (4.3, 5.0, 4.1) +# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders +# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch. +# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch. +# +# IOS_PLATFORM = OS (default) or SIMULATOR or ALL +# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders +# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch. +# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch. +# +# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder +# By default this location is automatcially chosen based on the IOS_PLATFORM value above. +# If set manually, it will override the default location and force the user of a particular Developer Platform +# +# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder +# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value. +# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path. +# If set manually, this will force the use of a specific SDK version + +IF(DEFINED CMAKE_CROSSCOMPILING) + # subsequent toolchain loading is not really needed + RETURN() +ENDIF() + +# Standard settings +SET(CMAKE_SYSTEM_NAME Darwin) +SET(CMAKE_SYSTEM_VERSION 1) # TODO: determine target Darwin version +SET(UNIX ON) +SET(APPLE ON) +SET(IOS ON) + +# Force the compilers to Clang for iOS +include (CMakeForceCompiler) +CMAKE_FORCE_C_COMPILER (clang Clang) +CMAKE_FORCE_CXX_COMPILER (clang++ Clang) + +# Setup iOS platform +if (NOT DEFINED IOS_PLATFORM) + set (IOS_PLATFORM "OS") +endif (NOT DEFINED IOS_PLATFORM) +set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform") + +SET(IOS_PLATFORM_LOCATION "iPhoneOS.platform") +SET(IOS_SIMULATOR_PLATFORM_LOCATION "iPhoneSimulator.platform") + +# Check the platform selection and setup for developer root +if (${IOS_PLATFORM} STREQUAL "OS") + # This causes the installers to properly locate the output libraries + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos") +elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR") + # This causes the installers to properly locate the output libraries + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator") +elseif (${IOS_PLATFORM} STREQUAL "ALL") + # This causes the installers to properly locate the output libraries + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator;-iphoneos") +else (${IOS_PLATFORM} STREQUAL "OS") + message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR") +endif (${IOS_PLATFORM} STREQUAL "OS") +set (CMAKE_XCODE_EFFECTIVE_PLATFORMS ${CMAKE_XCODE_EFFECTIVE_PLATFORMS} CACHE PATH "iOS Platform") + +# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT +# Note Xcode 4.3 changed the installation location, choose the most recent one available +SET(XCODE_POST_43_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms") +SET(XCODE_PRE_43_ROOT "/Developer/Platforms") + +IF(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) + IF(EXISTS ${XCODE_POST_43_ROOT}) + SET(CMAKE_XCODE_ROOT ${XCODE_POST_43_ROOT}) + ELSEIF(EXISTS ${XCODE_PRE_43_ROOT}) + SET(CMAKE_XCODE_ROOT ${XCODE_PRE_43_ROOT}) + ENDIF(EXISTS ${XCODE_POST_43_ROOT}) + IF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer) + SET(CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer) + ENDIF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer) + IF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer) + SET(CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer) + ENDIF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer) +ENDIF(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) +SET(CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform") +SET(CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT ${CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT} CACHE PATH "Location of iOS Simulator Platform") + +MACRO(GET_AVAILABLE_SDK_VERSIONS ROOT VERSIONS) + FILE(GLOB _CMAKE_IOS_SDKS "${ROOT}/SDKs/iPhoneOS*") + IF(_CMAKE_IOS_SDKS) + LIST(SORT _CMAKE_IOS_SDKS) + LIST(REVERSE _CMAKE_IOS_SDKS) + FOREACH(_CMAKE_IOS_SDK ${_CMAKE_IOS_SDKS}) + STRING(REGEX REPLACE ".+iPhoneOS([0-9.]+)\\.sdk" "\\1" _IOS_SDK "${_CMAKE_IOS_SDK}") + LIST(APPEND ${VERSIONS} ${_IOS_SDK}) + ENDFOREACH(_CMAKE_IOS_SDK) + ENDIF(_CMAKE_IOS_SDKS) +ENDMACRO(GET_AVAILABLE_SDK_VERSIONS) + +# Find and use the most recent iOS sdk +IF(NOT DEFINED CMAKE_IOS_SDK_ROOT) + # Search for a specific version of a SDK + GET_AVAILABLE_SDK_VERSIONS(${CMAKE_IOS_DEVELOPER_ROOT} IOS_VERSIONS) + + IF(NOT IOS_VERSIONS) + MESSAGE(FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.") + ENDIF(NOT IOS_VERSIONS) + + IF(IOS_VERSION) + LIST(FIND IOS_VERSIONS "${IOS_VERSION}" _INDEX) + IF(_INDEX EQUAL -1) + LIST(GET IOS_VERSIONS 0 IOS_SDK_VERSION) + ELSE(_INDEX EQUAL -1) + SET(IOS_SDK_VERSION ${IOS_VERSION}) + ENDIF(_INDEX EQUAL -1) + ELSE(IOS_VERSION) + LIST(GET IOS_VERSIONS 0 IOS_VERSION) + SET(IOS_SDK_VERSION ${IOS_VERSION}) + ENDIF(IOS_VERSION) + + MESSAGE(STATUS "Target iOS ${IOS_VERSION} and use SDK ${IOS_SDK_VERSION}") + + SET(CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/iPhoneOS${IOS_SDK_VERSION}.sdk) + SET(CMAKE_IOS_SIMULATOR_SDK_ROOT ${CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT}/SDKs/iPhoneSimulator${IOS_SDK_VERSION}.sdk) +endif (NOT DEFINED CMAKE_IOS_SDK_ROOT) + +SET(CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK") +SET(CMAKE_IOS_SIMULATOR_SDK_ROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Location of the selected iOS Simulator SDK") + +SET(IOS_VERSION ${IOS_VERSION} CACHE STRING "iOS target version") + +# Set the sysroot default to the most recent SDK +SET(CMAKE_IOS_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") +SET(CMAKE_IOS_SIMULATOR_SYSROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Sysroot used for iOS Simulator support") + +IF(CMAKE_GENERATOR MATCHES Xcode) + SET(ARCHS "$(ARCHS_STANDARD_32_BIT)") + IF(${IOS_PLATFORM} STREQUAL "OS") + SET(CMAKE_SYSTEM_PROCESSOR "armv7") + ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") + SET(CMAKE_SYSTEM_PROCESSOR "x86") + ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") + SET(CMAKE_SYSTEM_PROCESSOR "armv7") + ENDIF(${IOS_PLATFORM} STREQUAL "OS") +ELSE(CMAKE_GENERATOR MATCHES Xcode) + IF(${IOS_PLATFORM} STREQUAL "OS") + SET(ARCHS "armv7") + SET(CMAKE_SYSTEM_PROCESSOR "armv7") + ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") + # iPhone simulator targets i386 + SET(ARCHS "i386") + SET(CMAKE_SYSTEM_PROCESSOR "x86") + ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") + SET(ARCHS "armv7;i386") + SET(CMAKE_SYSTEM_PROCESSOR "armv7") + ENDIF(${IOS_PLATFORM} STREQUAL "OS") +ENDIF(CMAKE_GENERATOR MATCHES Xcode) + +# set the architecture for iOS - using ARCHS_STANDARD_32_BIT sets armv7,armv7s and appears to be XCode's standard. +# The other value that works is ARCHS_UNIVERSAL_IPHONE_OS but that sets armv7 only +set (CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE string "Build architecture for iOS") + +# Set the find root to the iOS developer roots and to user defined paths +set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} $ENV{EXTERNAL_IOS_PATH} CACHE string "iOS find search path root") + +# default to searching for frameworks first +set (CMAKE_FIND_FRAMEWORK FIRST) + +# set up the default search directories for frameworks +set (CMAKE_SYSTEM_FRAMEWORK_PATH + ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks + ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks + ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks +) + +# only search the iOS sdks, not the remainder of the host filesystem +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +#SET(CMAKE_SYSTEM_INCLUDE_PATH /include /usr/include) +#SET(CMAKE_SYSTEM_LIBRARY_PATH /lib /usr/lib) +#SET(CMAKE_SYSTEM_PROGRAM_PATH /bin /usr/bin) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index c70d6acde..bcd32d052 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -125,10 +125,6 @@ MACRO(NL_DEFAULT_PROPS name label) COMPILE_FLAGS "/GA" LINK_FLAGS "/VERSION:${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}") ENDIF(${type} STREQUAL EXECUTABLE AND WIN32) - - IF(WITH_STLPORT AND WIN32) - SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "/X") - ENDIF(WITH_STLPORT AND WIN32) ENDMACRO(NL_DEFAULT_PROPS) ### @@ -387,11 +383,11 @@ MACRO(NL_SETUP_BUILD) SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR}) - IF(HOST_CPU MATCHES "amd64|AMD64") + IF(HOST_CPU MATCHES "(amd|AMD)64") SET(HOST_CPU "x86_64") ELSEIF(HOST_CPU MATCHES "i.86") SET(HOST_CPU "x86") - ENDIF(HOST_CPU MATCHES "amd64|AMD64") + ENDIF(HOST_CPU MATCHES "(amd|AMD)64") # Determine target CPU @@ -400,11 +396,11 @@ MACRO(NL_SETUP_BUILD) SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) ENDIF(NOT TARGET_CPU) - IF(TARGET_CPU MATCHES "amd64|AMD64") + IF(TARGET_CPU MATCHES "(amd|AMD)64") SET(TARGET_CPU "x86_64") ELSEIF(TARGET_CPU MATCHES "i.86") SET(TARGET_CPU "x86") - ENDIF(TARGET_CPU MATCHES "amd64|AMD64") + ENDIF(TARGET_CPU MATCHES "(amd|AMD)64") IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") SET(CLANG ON) @@ -416,6 +412,11 @@ MACRO(NL_SETUP_BUILD) MESSAGE(STATUS "Generating Xcode project") ENDIF(CMAKE_GENERATOR MATCHES "Xcode") + IF(CMAKE_GENERATOR MATCHES "NMake") + SET(NMAKE ON) + MESSAGE(STATUS "Generating NMake project") + ENDIF(CMAKE_GENERATOR MATCHES "NMake") + # If target and host CPU are the same IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING) # x86-compatible CPU @@ -535,6 +536,9 @@ MACRO(NL_SETUP_BUILD) SET(MSVC11 ON) ENDIF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11) + # Ignore default include paths + ADD_PLATFORM_FLAGS("/X") + IF(MSVC11) ADD_PLATFORM_FLAGS("/Gy- /MP") # /Ox is working with VC++ 2010, but custom optimizations don't exist @@ -894,20 +898,23 @@ ENDMACRO(NL_SETUP_BUILD) MACRO(NL_SETUP_BUILD_FLAGS) SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE) ## Debug SET(CMAKE_C_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE) SET(CMAKE_CXX_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE) - SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE) ## Release SET(CMAKE_C_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE) SET(CMAKE_CXX_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE) - SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE) - SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE) - SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE) + SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) + SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE) ENDMACRO(NL_SETUP_BUILD_FLAGS) # Macro to create x_ABSOLUTE_PREFIX from x_PREFIX @@ -1061,74 +1068,14 @@ MACRO(SETUP_EXTERNAL) IF(WIN32) FIND_PACKAGE(External REQUIRED) - IF(NOT VC_DIR) - SET(VC_DIR $ENV{VC_DIR}) - ENDIF(NOT VC_DIR) - - IF(MSVC11) - IF(NOT MSVC_REDIST_DIR) - # If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist - SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist") - ENDIF(NOT MSVC_REDIST_DIR) - - IF(NOT VC_DIR) - IF(NOT VC_ROOT_DIR) - GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\11.0_Config;InstallDir]" ABSOLUTE) - # VC_ROOT_DIR is set to "registry" when a key is not found - IF(VC_ROOT_DIR MATCHES "registry") - GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\WDExpress\\11.0_Config\\Setup\\VC;InstallDir]" ABSOLUTE) - IF(VC_ROOT_DIR MATCHES "registry") - SET(VS110COMNTOOLS $ENV{VS110COMNTOOLS}) - IF(VS110COMNTOOLS) - FILE(TO_CMAKE_PATH ${VS110COMNTOOLS} VC_ROOT_DIR) - ENDIF(VS110COMNTOOLS) - IF(NOT VC_ROOT_DIR) - MESSAGE(FATAL_ERROR "Unable to find VC++ 2012 directory!") - ENDIF(NOT VC_ROOT_DIR) - ENDIF(VC_ROOT_DIR MATCHES "registry") - ENDIF(VC_ROOT_DIR MATCHES "registry") - ENDIF(NOT VC_ROOT_DIR) - # convert IDE fullpath to VC++ path - STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR}) - ENDIF(NOT VC_DIR) - ELSEIF(MSVC10) - IF(NOT MSVC_REDIST_DIR) - # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist - SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist") - ENDIF(NOT MSVC_REDIST_DIR) - - IF(NOT VC_DIR) - IF(NOT VC_ROOT_DIR) - GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0_Config;InstallDir]" ABSOLUTE) - # VC_ROOT_DIR is set to "registry" when a key is not found - IF(VC_ROOT_DIR MATCHES "registry") - GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE) - IF(VC_ROOT_DIR MATCHES "registry") - SET(VS100COMNTOOLS $ENV{VS100COMNTOOLS}) - IF(VS100COMNTOOLS) - FILE(TO_CMAKE_PATH ${VS100COMNTOOLS} VC_ROOT_DIR) - ENDIF(VS100COMNTOOLS) - IF(NOT VC_ROOT_DIR) - MESSAGE(FATAL_ERROR "Unable to find VC++ 2010 directory!") - ENDIF(NOT VC_ROOT_DIR) - ENDIF(VC_ROOT_DIR MATCHES "registry") - ENDIF(VC_ROOT_DIR MATCHES "registry") - ENDIF(NOT VC_ROOT_DIR) - # convert IDE fullpath to VC++ path - STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR}) - ENDIF(NOT VC_DIR) - ELSE(MSVC11) - IF(NOT VC_DIR) - IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") - # convert IDE fullpath to VC++ path - STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM}) - ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") - # convert compiler fullpath to VC++ path - STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER}) - ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") - ENDIF(NOT VC_DIR) - ENDIF(MSVC11) + # If using custom boost, we need to define the right variables used by official boost CMake module + IF(DEFINED BOOST_DIR) + SET(BOOST_INCLUDEDIR ${BOOST_DIR}/include) + SET(BOOST_LIBRARYDIR ${BOOST_DIR}/lib) + ENDIF(DEFINED BOOST_DIR) ELSE(WIN32) + FIND_PACKAGE(External QUIET) + IF(APPLE) IF(WITH_STATIC_EXTERNAL) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) @@ -1144,15 +1091,22 @@ MACRO(SETUP_EXTERNAL) ENDIF(APPLE) ENDIF(WIN32) + # Android and iOS have pthread + IF(ANDROID OR IOS) + SET(CMAKE_USE_PTHREADS_INIT 1) + SET(Threads_FOUND TRUE) + ELSE(ANDROID OR IOS) + FIND_PACKAGE(Threads REQUIRED) + # TODO: replace all -l by absolute path to in CMAKE_THREAD_LIBS_INIT + ENDIF(ANDROID OR IOS) + IF(WITH_STLPORT) FIND_PACKAGE(STLport REQUIRED) INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR}) - IF(MSVC) - SET(VC_INCLUDE_DIR "${VC_DIR}/include") - - FIND_PACKAGE(WindowsSDK REQUIRED) - # use VC++ and Windows SDK include paths - INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIRS}) - ENDIF(MSVC) ENDIF(WITH_STLPORT) + + IF(MSVC) + FIND_PACKAGE(MSVC REQUIRED) + FIND_PACKAGE(WindowsSDK REQUIRED) + ENDIF(MSVC) ENDMACRO(SETUP_EXTERNAL)