From b18b0fdf28444ae5d9d8bea1d3380eb1895f7314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Wed, 24 Dec 2014 13:15:54 -0500 Subject: [PATCH 01/11] Add TargetArch.cmake. For now just dump the original and add the BSD-2-Clause. . It's GPL compatible so it's okay. . I was writting one myself but found this one and it handles apple which I did not consider since I can't test it. --- cmake/TargetArch.cmake | 158 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 cmake/TargetArch.cmake diff --git a/cmake/TargetArch.cmake b/cmake/TargetArch.cmake new file mode 100644 index 0000000000..ffabda61d6 --- /dev/null +++ b/cmake/TargetArch.cmake @@ -0,0 +1,158 @@ +# Copyright (c) 2012 Petroules Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. 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 OWNER 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. +# +# https://github.com/petroules/solar-cmake/blob/master/TargetArch.cmake +# +# Based on the Qt 5 processor detection code, so should be very accurate +# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h +# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) + +# Regarding POWER/PowerPC, just as is noted in the Qt source, +# "There are many more known variants/revisions that we do not handle/detect." + +set(archdetect_c_code " +#if defined(__arm__) || defined(__TARGET_ARCH_ARM) + #if defined(__ARM_ARCH_7__) \\ + || defined(__ARM_ARCH_7A__) \\ + || defined(__ARM_ARCH_7R__) \\ + || defined(__ARM_ARCH_7M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) + #error cmake_ARCH armv7 + #elif defined(__ARM_ARCH_6__) \\ + || defined(__ARM_ARCH_6J__) \\ + || defined(__ARM_ARCH_6T2__) \\ + || defined(__ARM_ARCH_6Z__) \\ + || defined(__ARM_ARCH_6K__) \\ + || defined(__ARM_ARCH_6ZK__) \\ + || defined(__ARM_ARCH_6M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) + #error cmake_ARCH armv6 + #elif defined(__ARM_ARCH_5TEJ__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) + #error cmake_ARCH armv5 + #else + #error cmake_ARCH arm + #endif +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) + #error cmake_ARCH i386 +#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) + #error cmake_ARCH x86_64 +#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) + #error cmake_ARCH ia64 +#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ + || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ + || defined(_M_MPPC) || defined(_M_PPC) + #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) + #error cmake_ARCH ppc64 + #else + #error cmake_ARCH ppc + #endif +#endif + +#error cmake_ARCH unknown +") + +# Set ppc_support to TRUE before including this file or ppc and ppc64 +# will be treated as invalid architectures since they are no longer supported by Apple + +function(target_architecture output_var) + if(APPLE AND CMAKE_OSX_ARCHITECTURES) + # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set + # First let's normalize the order of the values + + # Note that it's not possible to compile PowerPC applications if you are using + # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we + # disable it by default + # See this page for more information: + # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 + + # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. + # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. + + foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) + if("${osx_arch}" STREQUAL "ppc" AND ppc_support) + set(osx_arch_ppc TRUE) + elseif("${osx_arch}" STREQUAL "i386") + set(osx_arch_i386 TRUE) + elseif("${osx_arch}" STREQUAL "x86_64") + set(osx_arch_x86_64 TRUE) + elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) + set(osx_arch_ppc64 TRUE) + else() + message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") + endif() + endforeach() + + # Now add all the architectures in our normalized order + if(osx_arch_ppc) + list(APPEND ARCH ppc) + endif() + + if(osx_arch_i386) + list(APPEND ARCH i386) + endif() + + if(osx_arch_x86_64) + list(APPEND ARCH x86_64) + endif() + + if(osx_arch_ppc64) + list(APPEND ARCH ppc64) + endif() + else() + file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") + + enable_language(C) + + # Detect the architecture in a rather creative way... + # This compiles a small C program which is a series of ifdefs that selects a + # particular #error preprocessor directive whose message string contains the + # target architecture. The program will always fail to compile (both because + # file is not a valid C program, and obviously because of the presence of the + # #error preprocessor directives... but by exploiting the preprocessor in this + # way, we can detect the correct target architecture even when cross-compiling, + # since the program itself never needs to be run (only the compiler/preprocessor) + try_run( + run_result_unused + compile_result_unused + "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}/arch.c" + COMPILE_OUTPUT_VARIABLE ARCH + CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + ) + + # Parse the architecture name from the compiler output + string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") + + # Get rid of the value marker leaving just the architecture name + string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") + + # If we are compiling with an unknown architecture this variable should + # already be set to "unknown" but in the case that it's empty (i.e. due + # to a typo in the code), then set it to unknown + if (NOT ARCH) + set(ARCH unknown) + endif() + endif() + + set(${output_var} "${ARCH}" PARENT_SCOPE) +endfunction() From e548ada1e922e9588b3d1d96dd26f156205bfe96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Wed, 24 Dec 2014 14:54:03 -0500 Subject: [PATCH 02/11] Disable the use of multiple architectures in darwin. - Update copyright due to incoming changes. - Don't support universal binaries until they actually work therefore only allow 1 architecture in CMAKE_OSX_ARCHITECTURES. - Don't allow an empty ARCH list. We probably asked for ppc or ppc64 w/o support for it. --- cmake/TargetArch.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/TargetArch.cmake b/cmake/TargetArch.cmake index ffabda61d6..ee144bc1fd 100644 --- a/cmake/TargetArch.cmake +++ b/cmake/TargetArch.cmake @@ -1,3 +1,4 @@ +# Copyright (c) 2014 PCSX2 Dev Team # Copyright (c) 2012 Petroules Corporation. All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -88,6 +89,11 @@ function(target_architecture output_var) # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. + LIST(LENGTH CMAKE_OSX_ARCHITECTURES osx_arch_num) + if(NOT (osx_arch_num EQUAL 1)) + message(FATAL_ERROR "Currently ${CMAKE_PROJECT_NAME} does not support multiple architectures in CMAKE_OSX_ARCHITECTURES") + endif() + foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) if("${osx_arch}" STREQUAL "ppc" AND ppc_support) set(osx_arch_ppc TRUE) @@ -118,6 +124,11 @@ function(target_architecture output_var) if(osx_arch_ppc64) list(APPEND ARCH ppc64) endif() + + LIST(LENGTH ARCH osx_arch_num) + if(osx_arch_num LESS 1) + message(FATAL_ERROR "Invalid CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}") + endif() else() file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") From 8ea0766773d255f3a3601536e06edf6891c1b731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Wed, 24 Dec 2014 15:39:51 -0500 Subject: [PATCH 03/11] Use TargetArch to correctly detect the target. Currently crosscompiling was broken since we detected the cpu of the host not of the target. Building arm -> i386, i386->amd64, etc resulted in interesting stuff. . CMAKE_HOST_SYSTEM_PROCESSOR and CMAKE_SYSTEM_PROCESSOR should have done this but they are incredibly broken and unreliable. I use CMAKE_HOST_SYSTEM_PROCESSOR just to retain the format of the old message and is not used for critical stuff so it does not matter. . This code also allows scalability so that if one day in the very distant and unlikely future the x86/x86_64 specific code gets made portable by replacing asm/MMX/SSE*/AVX/etc code with generic/portable code then it also would work on all architectures. . For *BSD/OS X it probably would need to use POSIX AIO instead of linux specific libaio but that is a different issue. . Error out the x86_64 builds. Also the 64BIT_BUILD_DONT_WORK option became obsolete more info in following commit. --- cmake/BuildParameters.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 3caab734af..b19975e155 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -70,11 +70,19 @@ option(64BIT_BUILD_DONT_WORK "Enable a x86_64 build instead of cross compiling ( option(DISABLE_ADVANCE_SIMD "Disable advance use of SIMD (SSE2+ & AVX)" OFF) # Architecture bitness detection -if(CMAKE_SIZEOF_VOID_P EQUAL 8) +include(TargetArch) +target_architecture(PCSX2_TARGET_ARCHITECTURES) +if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64") set(_ARCH_64 1) -else() + if(CMAKE_BUILD_TYPE MATCHES "Release" OR PACKAGE_MODE) + message(FATAL_ERROR "The ${PCSX2_TARGET_ARCHITECTURES} architecture is not ready yet.") + endif() +elseif(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") set(_ARCH_32 1) +else() + message(FATAL_ERROR "Unsupported architecture: ${PCSX2_TARGET_ARCHITECTURES}") endif() +message(STATUS "Compiling a ${PCSX2_TARGET_ARCHITECTURES} build on a ${CMAKE_HOST_SYSTEM_PROCESSOR} host.") # Print a clear message that 64bits is not supported if(_ARCH_64) @@ -87,7 +95,6 @@ endif() # 64 bits cross-compile specific configuration if(_ARCH_64 AND 64BIT_BUILD_DONT_WORK) - message("Compiling 64bit build on 64bit architecture") # Search library in /usr/lib64 SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) # Probably useless but it will not harm @@ -114,7 +121,6 @@ if(_ARCH_64 AND 64BIT_BUILD_DONT_WORK) set(_M_X86 1) set(_M_X86_64 1) else() - message("Compiling 32bit build on 32/64bit architecture") # Do not search library in /usr/lib64 SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) # Probably useless but it will not harm From d6d06d243c282d9268b51a28a06a1a0e08717d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Wed, 24 Dec 2014 17:12:34 -0500 Subject: [PATCH 04/11] Begin cleaning up the cross build code. http://www.vtk.org/Wiki/CMake_Cross_Compiling http://www.cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html . The official way that cmake does cross compiling is via the use of a CMAKE_TOOLCHAIN_FILE. This has to be given by the user and can't be included from within a Cmake file since setting up the toolchain has to be the first thing that happens. . After the file is given and validated cmake behaves nicely and all the workarounds and hacks are not really needed anymore. . The consequence of this change is that without this file cmake will try to build for the HOST architecture as expected and with the file it will build for the TARGET architecture of the given toolchain. Due to this remove 64BIT_BUILD_DONT_WORK and just ERROR out if the user tries in the same way as before. --- build.sh | 2 - cmake/BuildParameters.cmake | 100 +++++++++++++++--------------------- cmake/SearchForStuff.cmake | 26 ---------- 3 files changed, 40 insertions(+), 88 deletions(-) diff --git a/build.sh b/build.sh index b11a896428..160b6cb30e 100755 --- a/build.sh +++ b/build.sh @@ -41,7 +41,6 @@ for ARG in "$@"; do --asan ) flags+=(-DUSE_ASAN=TRUE) ;; --wx28 ) flags+=(-DWX28_API=TRUE) ;; --gtk3 ) flags+=(-DGTK3_API=TRUE) ;; - --64-bit-dont-work ) flags+=(-D64BIT_BUILD_DONT_WORK=TRUE) ;; --no-simd ) flags+=(-DDISABLE_ADVANCE_SIMD=TRUE) ;; -D* ) flags+=($ARG) ;; @@ -66,7 +65,6 @@ for ARG in "$@"; do echo "--gles : Replace openGL backend of GSdx by openGLES3.1" echo echo "** Hardcode Developper option **" - echo "--64-bit-dont-work : Don't use it!" echo "--no-simd : Only allow sse2" echo "--gtk3 : replace GTK2 by GTK3" exit 1 diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index b19975e155..6e3d5eb5fb 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -66,75 +66,30 @@ option(USE_ASAN "Enable address sanitizer") #------------------------------------------------------------------------------- # Select the architecture #------------------------------------------------------------------------------- -option(64BIT_BUILD_DONT_WORK "Enable a x86_64 build instead of cross compiling (WARNING: NOTHING WORK)" OFF) option(DISABLE_ADVANCE_SIMD "Disable advance use of SIMD (SSE2+ & AVX)" OFF) # Architecture bitness detection include(TargetArch) target_architecture(PCSX2_TARGET_ARCHITECTURES) -if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64") - set(_ARCH_64 1) - if(CMAKE_BUILD_TYPE MATCHES "Release" OR PACKAGE_MODE) +if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64" OR ${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") + if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64" AND (CMAKE_BUILD_TYPE MATCHES "Release" OR PACKAGE_MODE)) message(FATAL_ERROR "The ${PCSX2_TARGET_ARCHITECTURES} architecture is not ready yet.") endif() -elseif(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") - set(_ARCH_32 1) + message(STATUS "Compiling a ${PCSX2_TARGET_ARCHITECTURES} build on a ${CMAKE_HOST_SYSTEM_PROCESSOR} host.") else() message(FATAL_ERROR "Unsupported architecture: ${PCSX2_TARGET_ARCHITECTURES}") endif() -message(STATUS "Compiling a ${PCSX2_TARGET_ARCHITECTURES} build on a ${CMAKE_HOST_SYSTEM_PROCESSOR} host.") -# Print a clear message that 64bits is not supported -if(_ARCH_64) +# Print a clear message that most architectures are not supported +if(NOT (${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386")) message(WARNING " - PCSX2 does not support a 64-bits environment and has no yet a plan to support it. + PCSX2 does not support the ${PCSX2_TARGET_ARCHITECTURES} architecture and has no plans yet to support it. It would need a complete rewrite of the core emulator and a lot of time. - You can still run a 32-bits binary if you install all 32-bits libraries (runtime and dev).") + You can still run a i386 binary if you install all the i386 libraries (runtime and dev).") endif() -# 64 bits cross-compile specific configuration -if(_ARCH_64 AND 64BIT_BUILD_DONT_WORK) - # Search library in /usr/lib64 - SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) - # Probably useless but it will not harm - SET_PROPERTY(GLOBAL PROPERTY COMPILE_DEFINITIONS "-m64") - - # Note: /usr/lib64 is already taken care above - - # For Debian/ubuntu multiarch - if(EXISTS "/usr/lib/x86_64-linux-gnu") - set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") - endif() - - # x86_64 requires -fPIC - set(CMAKE_POSITION_INDEPENDENT_CODE ON) - - if (DISABLE_ADVANCE_SIMD) - set(ARCH_FLAG "-m64 -msse -msse2") - else() - #set(ARCH_FLAG "-m64 -march=native -fabi-version=6") - set(ARCH_FLAG "-m64 -march=native") - endif() - add_definitions(-D_ARCH_64=1 -D_M_X86=1 -D_M_X86_64=1) - set(_ARCH_64 1) - set(_M_X86 1) - set(_M_X86_64 1) -else() - # Do not search library in /usr/lib64 - SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) - # Probably useless but it will not harm - SET_PROPERTY(GLOBAL PROPERTY COMPILE_DEFINITIONS "-m32") - - # Force the search on 32-bits path. - if(EXISTS "/usr/lib32") - set(CMAKE_LIBRARY_ARCHITECTURE "../lib32") - endif() - # Debian/ubuntu drop /usr/lib32 and move /usr/lib to /usr/lib/i386-linux-gnu - if(EXISTS "/usr/lib/i386-linux-gnu") - set(CMAKE_LIBRARY_ARCHITECTURE "i386-linux-gnu") - endif() - +if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") # * -fPIC option was removed for multiple reasons. # - Code only supports the x86 architecture. # - code uses the ebx register so it's not compliant with PIC. @@ -142,18 +97,46 @@ else() # - Only plugins. No package will link to them. set(CMAKE_POSITION_INDEPENDENT_CODE OFF) + # Do not search library in /usr/lib64 + SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) + if (DISABLE_ADVANCE_SIMD) - set(ARCH_FLAG "-m32 -msse -msse2 -march=i686") + set(ARCH_FLAG "-msse -msse2 -march=i686") else() # AVX requires some fix of the ABI (mangling) (default 2) # Note: V6 requires GCC 4.7 - #set(ARCH_FLAG "-m32 -march=native -fabi-version=6") - set(ARCH_FLAG "-m32 -march=native") + #set(ARCH_FLAG "-march=native -fabi-version=6") + set(ARCH_FLAG "-march=native") endif() add_definitions(-D_ARCH_32=1 -D_M_X86=1 -D_M_X86_32=1) set(_ARCH_32 1) set(_M_X86 1) set(_M_X86_32 1) +elseif(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64") + # x86_64 requires -fPIC + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Search library in /usr/lib64 (Arch Linux) + SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) + + if (DISABLE_ADVANCE_SIMD) + set(ARCH_FLAG "-msse -msse2") + else() + #set(ARCH_FLAG "-march=native -fabi-version=6") + set(ARCH_FLAG "-march=native") + endif() + add_definitions(-D_ARCH_64=1 -D_M_X86=1 -D_M_X86_64=1) + set(_ARCH_64 1) + set(_M_X86 1) + set(_M_X86_64 1) +else() + # All but i386 requires -fPIC + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Do not search library in /usr/lib64 + SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) + + message(FATAL_ERROR "Unsupported architecture: ${PCSX2_TARGET_ARCHITECTURES}") endif() #------------------------------------------------------------------------------- @@ -212,7 +195,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "") # Remove -rdynamic option that can some segmentation fault when openining pcsx2 plugins set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") -if(_ARCH_32) +if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") # Remove -fPIC option on 32bit architectures. # No good reason to use it for plugins, also it impacts performance. set(CMAKE_SHARED_LIBRARY_C_FLAGS "") @@ -303,9 +286,6 @@ string(STRIP "${CMAKE_CXX_FLAGS} ${DEFAULT_CPP_FLAG}" CMAKE_CXX_FLAGS) # Too much user/packager use experimental flags as release flags #------------------------------------------------------------------------------- if(CMAKE_BUILD_TYPE MATCHES "Release" OR PACKAGE_MODE) - if (64BIT_BUILD_DONT_WORK) - message(FATAL_ERROR "64 bit is not suitable for end users. It will only crash and it will be 10 times slower than 32 bits !!!") - endif() if (GTK3_API) message(FATAL_ERROR "GTK3 is highly experimental besides it requires a wxWidget built with __WXGTK3__ support !!!") endif() diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 8e2f147a1b..b11101c4b6 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -101,25 +101,6 @@ endif() if(wxWidgets_FOUND) if(Linux) - # Force the use of 32 bit library configuration on - # 64 bits machine with 32 bits library in /usr/lib32 - if(_ARCH_64 AND NOT 64BIT_BUILD_DONT_WORK) - ## There is no guarantee that wx-config is a link to a 32 bits library. So you need to force the destinity - # Library can go into 3 path major paths (+ multiarch) - # 1/ /usr/lib32 (32 bits only) - # 2/ /usr/lib64 (64 bits only) - # 3/ /usr/lib (32 or 64 bits depends on distributions) - if (EXISTS "/usr/lib32/wx") - STRING(REGEX REPLACE "/usr/lib/wx" "/usr/lib32/wx" wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}") - STRING(REGEX REPLACE "/usr/lib64/wx" "/usr/lib32/wx" wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}") - endif (EXISTS "/usr/lib32/wx") - if (EXISTS "/usr/lib/wx") - STRING(REGEX REPLACE "/usr/lib64/wx" "/usr/lib/wx" wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}") - endif (EXISTS "/usr/lib/wx") - # Multiarch ubuntu/debian - STRING(REGEX REPLACE "/usr/lib/x86_64-linux-gnu" "/usr/lib/i386-linux-gnu" wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}") - endif() - # Some people are trying to compile with wx 3.0 ... ### 3.0 # -I/usr/lib/i386-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread @@ -151,10 +132,3 @@ include_directories(${CMAKE_SOURCE_DIR}/common/include # File generated by Cmake ${CMAKE_BINARY_DIR}/common/include ) - -# WORKAROUND Some issue with multiarch on Debian/Ubuntu -if (64BIT_BUILD_DONT_WORK) - include_directories(/usr/include/x86_64-linux-gnu) -else() - include_directories(/usr/include/i386-linux-gnu) -endif() From b03ca5fcf403e3931981fb39bea5e15f41ab96b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Wed, 24 Dec 2014 18:15:55 -0500 Subject: [PATCH 05/11] Include some rather simple CMAKE_TOOLCHAIN_FILE. - Update the build.sh and fix some typos. + Don't add the OSX ones because I have not tested them and it won't even build anyway due to the libaio dependency. Needs to use POSIX AIO or something else. - They are rather simple and all the magic happens in two lines. + First line tells cmake to get ready to compile FOR linux or darwin. It also sets CMAKE_CROSSCOMPILING to true which is the only way to let cmake known that we are using stuff not from the host. + CMAKE_C_COMPILER/CMAKE_CXX_COMPILER are basically used to detect the architecture of the target. Since I used generic cc/c++ the hardcoded -m32 is needed to ensure we get TARGET=i386. Also since I hardcode -m32 and use c++/cc it's to be noted that we can only do i386->i386 (trivial), amd64 -> i386, and x32->i386. . Using something like i586-linux-gnu-{gcc,g++} would also work and enable arm -> i386, etc but it's infeasible and impractical to do all the combinations. File is simple enough that a distro or user can create their own and cross compiling is rather tedious compared to using a chroot to compile it. - I tested it in Debian with "dpkg-buildpackage -ai386" but installing the build dependencies was rather tedious. --- build.sh | 8 +++++--- cmake/darwin-compiler-i386-clang.cmake | 20 ++++++++++++++++++++ cmake/darwin-compiler-i386-generic.cmake | 15 +++++++++++++++ cmake/linux-compiler-i386-multilib.cmake | 16 ++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 cmake/darwin-compiler-i386-clang.cmake create mode 100644 cmake/darwin-compiler-i386-generic.cmake create mode 100644 cmake/linux-compiler-i386-multilib.cmake diff --git a/build.sh b/build.sh index 160b6cb30e..6a9c64bb82 100755 --- a/build.sh +++ b/build.sh @@ -42,6 +42,7 @@ for ARG in "$@"; do --wx28 ) flags+=(-DWX28_API=TRUE) ;; --gtk3 ) flags+=(-DGTK3_API=TRUE) ;; --no-simd ) flags+=(-DDISABLE_ADVANCE_SIMD=TRUE) ;; + --cross-multilib ) flags+=(-DCMAKE_TOOLCHAIN_FILE=cmake/linux-compiler-i386-multilib.cmake) ;; -D* ) flags+=($ARG) ;; *) @@ -54,17 +55,18 @@ for ARG in "$@"; do echo "--clean : Do a clean build." echo "--extra : Build all plugins" echo - echo "** Developper option **" + echo "** Developer option **" echo "--clang : Build with Clang/llvm" echo "--asan : Enable Address sanitizer" echo echo "--wx28 : Force wxWidget 2.8" echo "--glsl : Replace CG backend of ZZogl by GLSL" echo "--egl : Replace GLX by EGL (ZZogl plugins only)" - echo "--sdl2 : Build with SDL2 (crash if wx is linked to SDL1)" + echo "--sdl2 : Build with SDL2 (crashes if wx is linked to SDL1.2)" echo "--gles : Replace openGL backend of GSdx by openGLES3.1" + echo "--cross-multilib: Build a 32bit PCSX2 on a 64bit machine using multilib." echo - echo "** Hardcode Developper option **" + echo "** Hardcode Developer option **" echo "--no-simd : Only allow sse2" echo "--gtk3 : replace GTK2 by GTK3" exit 1 diff --git a/cmake/darwin-compiler-i386-clang.cmake b/cmake/darwin-compiler-i386-clang.cmake new file mode 100644 index 0000000000..182a6d4a91 --- /dev/null +++ b/cmake/darwin-compiler-i386-clang.cmake @@ -0,0 +1,20 @@ +# Tell cmake we are cross compiling and targeting darwin +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# Use clang and target i686-apple-darwin. +set(CMAKE_C_COMPILER clang -m32) +set(CMAKE_C_COMPILER_TARGET i686-apple-darwin) +set(CMAKE_CXX_COMPILER clang++ -m32) +set(CMAKE_CXX_COMPILER_TARGET i686-apple-darwin) + +# Enable clang +set(USE_CLANG TRUE) + +# If given a CMAKE_FIND_ROOT_PATH then +# FIND_PROGRAM ignores CMAKE_FIND_ROOT_PATH (probably can't run) +# FIND_{LIBRARY,INCLUDE,PACKAGE} only uses the files in CMAKE_FIND_ROOT_PATH. +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_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/cmake/darwin-compiler-i386-generic.cmake b/cmake/darwin-compiler-i386-generic.cmake new file mode 100644 index 0000000000..b2ac14e6a3 --- /dev/null +++ b/cmake/darwin-compiler-i386-generic.cmake @@ -0,0 +1,15 @@ +# Tell cmake we are cross compiling and targeting darwin +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# Leave it generic since it could be clang, gnu, etc. +set(CMAKE_C_COMPILER cc -m32) +set(CMAKE_CXX_COMPILER c++ -m32) + +# If given a CMAKE_FIND_ROOT_PATH then +# FIND_PROGRAM ignores CMAKE_FIND_ROOT_PATH (probably can't run) +# FIND_{LIBRARY,INCLUDE,PACKAGE} only uses the files in CMAKE_FIND_ROOT_PATH. +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_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/cmake/linux-compiler-i386-multilib.cmake b/cmake/linux-compiler-i386-multilib.cmake new file mode 100644 index 0000000000..ddf7ceaf5d --- /dev/null +++ b/cmake/linux-compiler-i386-multilib.cmake @@ -0,0 +1,16 @@ +# Tell cmake we are cross compiling and targeting linux +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# It could be i?86-*linux-gnu, x86_64-*linux-gnu, x86_64-*linux-gnux32, etc. +# Leave it generic to only support amd64 or x32 to i386 with any compiler. +set(CMAKE_C_COMPILER cc -m32) +set(CMAKE_CXX_COMPILER c++ -m32) + +# If given a CMAKE_FIND_ROOT_PATH then +# FIND_PROGRAM ignores CMAKE_FIND_ROOT_PATH (probably can't run) +# FIND_{LIBRARY,INCLUDE,PACKAGE} only uses the files in CMAKE_FIND_ROOT_PATH. +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_FIND_ROOT_PATH_MODE_PACKAGE ONLY) From 553536f9cb0f4d5756fe890f3ba64a62aa6b3d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Wed, 24 Dec 2014 21:18:28 -0500 Subject: [PATCH 06/11] Fix build in Fedora and print a confimation of cross compilation. - Fedora only needs --arch if cross compiling. + It's only used to select libdir so i386=i686=i986 - Messages are nice to debug build logs. . Everything seems to work unless some other distro broke. Other distros need to add CMAKE_TOOLCHAIN_FILE or --cross-multilib if they cross compiled amd64 -> i686. --- cmake/BuildParameters.cmake | 9 ++++++++- cmake/SearchForStuff.cmake | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 6e3d5eb5fb..0c55ad1286 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -68,12 +68,19 @@ option(USE_ASAN "Enable address sanitizer") #------------------------------------------------------------------------------- option(DISABLE_ADVANCE_SIMD "Disable advance use of SIMD (SSE2+ & AVX)" OFF) +# Print if we are cross compiling. +if(CMAKE_CROSSCOMPILING) + message(STATUS "Cross compilation is enabled.") +else() + message(STATUS "Cross compilation is disabled.") +endif() + # Architecture bitness detection include(TargetArch) target_architecture(PCSX2_TARGET_ARCHITECTURES) if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64" OR ${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64" AND (CMAKE_BUILD_TYPE MATCHES "Release" OR PACKAGE_MODE)) - message(FATAL_ERROR "The ${PCSX2_TARGET_ARCHITECTURES} architecture is not ready yet.") + message(FATAL_ERROR "The code for ${PCSX2_TARGET_ARCHITECTURES} support is not ready yet.") endif() message(STATUS "Compiling a ${PCSX2_TARGET_ARCHITECTURES} build on a ${CMAKE_HOST_SYSTEM_PROCESSOR} host.") else() diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index b11101c4b6..88c9b1cdb4 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -15,8 +15,10 @@ find_package(OpenGL) # set(wxWidgets_CONFIG_OPTIONS --unicode=yes --debug=yes) # In case someone want to debug inside wx # # Fedora uses an extra non-standard option ... Arch must be the first option. -if(Fedora) - set(wxWidgets_CONFIG_OPTIONS --arch i686 --unicode=yes) +# They do uname -m if missing so only fix for cross compilations. +# http://pkgs.fedoraproject.org/cgit/wxGTK.git/plain/wx-config +if(Fedora AND CMAKE_CROSSCOMPILING) + set(wxWidgets_CONFIG_OPTIONS --arch ${PCSX2_TARGET_ARCHITECTURES} --unicode=yes) else() set(wxWidgets_CONFIG_OPTIONS --unicode=yes) endif() From bed7a4f92e400293d62c22e2d41ab030a422b522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Sat, 27 Dec 2014 15:37:00 -0500 Subject: [PATCH 07/11] Be really strict about dependencies. The obtained binaries before and after this commit are identical (sha1sum) when compiled in Debian/Ubuntu/Fedora/ArchLinux. . The linker will always pick the 32bit libraries the only thing this does is make sure we have all the 32bit dependencies installed. Basically we avoid detecting the 64bit libraries and telling the users the 32bit libraries were found. We always link with 32bit libraries therefore this avoids having to wait 5-10min to just be told -lXXX is missing. . The only thing really needed are set(CMAKE_LIBRARY_ARCHITECTURE "../lib32") set(CMAKE_LIBRARY_ARCHITECTURE ".") . which basically ensures we don't pick 64bit headers since CMAKE_LIBRARY_ARCHITECTURE always gets tested first and for some reason FindGTK2 test searches lib64 first then lib32/lib. These values are hardcoded. Right now these arch specific headers are not used but can't say this will always be true. . FIND_LIBRARY_USE_LIB64_PATHS is not needed for native builds and it's covered by CMAKE_SYSTEM_IGNORE_PATH. . NOTE: We filter out lib32 because multilib is not compatible with multiarch. --- cmake/BuildParameters.cmake | 9 ------- cmake/linux-compiler-i386-multilib.cmake | 31 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 0c55ad1286..88db4daf92 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -104,9 +104,6 @@ if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") # - Only plugins. No package will link to them. set(CMAKE_POSITION_INDEPENDENT_CODE OFF) - # Do not search library in /usr/lib64 - SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) - if (DISABLE_ADVANCE_SIMD) set(ARCH_FLAG "-msse -msse2 -march=i686") else() @@ -123,9 +120,6 @@ elseif(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64") # x86_64 requires -fPIC set(CMAKE_POSITION_INDEPENDENT_CODE ON) - # Search library in /usr/lib64 (Arch Linux) - SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) - if (DISABLE_ADVANCE_SIMD) set(ARCH_FLAG "-msse -msse2") else() @@ -140,9 +134,6 @@ else() # All but i386 requires -fPIC set(CMAKE_POSITION_INDEPENDENT_CODE ON) - # Do not search library in /usr/lib64 - SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) - message(FATAL_ERROR "Unsupported architecture: ${PCSX2_TARGET_ARCHITECTURES}") endif() diff --git a/cmake/linux-compiler-i386-multilib.cmake b/cmake/linux-compiler-i386-multilib.cmake index ddf7ceaf5d..770f38b483 100644 --- a/cmake/linux-compiler-i386-multilib.cmake +++ b/cmake/linux-compiler-i386-multilib.cmake @@ -7,6 +7,37 @@ set(CMAKE_SYSTEM_PROCESSOR i686) set(CMAKE_C_COMPILER cc -m32) set(CMAKE_CXX_COMPILER c++ -m32) +# cmake 2.8.5 correctly sets CMAKE_LIBRARY_ARCHITECTURE for Debian multiarch. +# Be really strict about what gets used. +if(EXISTS /usr/lib/i386-linux-gnu) + set(CMAKE_SYSTEM_IGNORE_PATH + /lib /lib64 /lib32 + /usr/lib /usr/lib64 /usr/lib32 + /usr/local/lib /usr/local/lib64 /usr/local/lib32) + list(APPEND CMAKE_LIBRARY_PATH /usr/local/lib/i386-linux-gnu) + list(APPEND CMAKE_LIBRARY_PATH /usr/lib/i386-linux-gnu) + list(APPEND CMAKE_LIBRARY_PATH /lib/i386-linux-gnu) +elseif(EXISTS /usr/lib32) + set(CMAKE_SYSTEM_IGNORE_PATH + /lib /lib64 + /usr/lib /usr/lib64 + /usr/local/lib /usr/local/lib64) + set(CMAKE_LIBRARY_ARCHITECTURE "../lib32") + list(APPEND CMAKE_LIBRARY_PATH /usr/local/lib32) + list(APPEND CMAKE_LIBRARY_PATH /usr/lib32) + list(APPEND CMAKE_LIBRARY_PATH /lib32) +else() + set(CMAKE_SYSTEM_IGNORE_PATH + /lib64 + /usr/lib64 + /usr/local/lib64) + set(CMAKE_LIBRARY_ARCHITECTURE ".") + list(APPEND CMAKE_LIBRARY_PATH /usr/local/lib) + list(APPEND CMAKE_LIBRARY_PATH /usr/lib) + list(APPEND CMAKE_LIBRARY_PATH /lib) +endif() +list(REMOVE_DUPLICATES CMAKE_LIBRARY_PATH) + # If given a CMAKE_FIND_ROOT_PATH then # FIND_PROGRAM ignores CMAKE_FIND_ROOT_PATH (probably can't run) # FIND_{LIBRARY,INCLUDE,PACKAGE} only uses the files in CMAKE_FIND_ROOT_PATH. From b42c9defb1f2471f031860248c1a29894a687c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Sat, 27 Dec 2014 22:15:08 -0500 Subject: [PATCH 08/11] Avoid PKG_CONFIG_PATH issues. Even before this pull request it was required to set PKG_CONFIG_PATH when cross compiling since pkg-config always searches for native libraries. This would require to backup an already existing ENV variable if present, detect the distro specific place the pkgconfig folder is, and restore the original ENV variable if it was present. Cmake as shown in: . http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3df51470 . added support for this but requires CMAKE_MINIMUM_REQUIRED_VERSION as 3.1 which is kind of strict since it was released 10 days ago. . To avoid the ugliness let just avoid pkg-config when cross compiling. This means only EGL, SDL2 and GTK3 have to be updated since the rest work w/o pkg-config. - EGL is fixed with PR #409 - SDL2 is fixed here and it's trivial. - GTK3 is non-trivial. For this one use pkg-config for native builds since the .pc file is kept up to date automatically. For cross compilation use the provided FindGTK3 which I made by using the sed documented inside the file and updating the dependencies for GTK3. Since I checked each and every single .pc file to make sure they are up to date this should have the same behaviour as pkg-config. Prefer the .pc files for native builds since it does not need to be manually updated and when the native 64bit port gets finished all the cross compile options should be removed which is quite easy since most of the code got moved to the CMAKE_TOOLCHAIN_FILE. Note: Cmake Modules are BSD-3-clause therefore GPL compatible. --- cmake/CheckLib.cmake | 2 +- cmake/FindGTK3.cmake | 919 +++++++++++++++++++++++++++++++++++++ cmake/SearchForStuff.cmake | 8 +- 3 files changed, 926 insertions(+), 3 deletions(-) create mode 100644 cmake/FindGTK3.cmake diff --git a/cmake/CheckLib.cmake b/cmake/CheckLib.cmake index 1b7e7f1778..d91adc3b62 100644 --- a/cmake/CheckLib.cmake +++ b/cmake/CheckLib.cmake @@ -7,7 +7,7 @@ endmacro() macro(check_lib var lib) set(_arg_list ${ARGN}) - if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND) + if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND AND NOT CMAKE_CROSSCOMPILING) string(TOLOWER ${lib} lower_lib) pkg_search_module(${var} QUIET ${lower_lib}) endif() diff --git a/cmake/FindGTK3.cmake b/cmake/FindGTK3.cmake new file mode 100644 index 0000000000..78e8266729 --- /dev/null +++ b/cmake/FindGTK3.cmake @@ -0,0 +1,919 @@ +#.rst: +# FindGTK3 +# -------- +# +# FindGTK3.cmake +# +# This module can find the GTK3 widget libraries and several of its +# other optional components like gtkmm, glade, and glademm. +# +# NOTE: If you intend to use version checking, CMake 2.6.2 or later is +# +# :: +# +# required. +# +# +# +# Specify one or more of the following components as you call this find +# module. See example below. +# +# :: +# +# gtk +# gtkmm +# glade +# glademm +# +# +# +# The following variables will be defined for your use +# +# :: +# +# GTK3_FOUND - Were all of your specified components found? +# GTK3_INCLUDE_DIRS - All include directories +# GTK3_LIBRARIES - All libraries +# GTK3_DEFINITIONS - Additional compiler flags +# +# +# +# :: +# +# GTK3_VERSION - The version of GTK3 found (x.y.z) +# GTK3_MAJOR_VERSION - The major version of GTK3 +# GTK3_MINOR_VERSION - The minor version of GTK3 +# GTK3_PATCH_VERSION - The patch version of GTK3 +# +# +# +# Optional variables you can define prior to calling this module: +# +# :: +# +# GTK3_DEBUG - Enables verbose debugging of the module +# GTK3_ADDITIONAL_SUFFIXES - Allows defining additional directories to +# search for include files +# +# +# +# ================= Example Usage: +# +# :: +# +# Call find_package() once, here are some examples to pick from: +# +# +# +# :: +# +# Require GTK 3.6 or later +# find_package(GTK3 3.6 REQUIRED gtk) +# +# +# +# :: +# +# Require GTK 3.10 or later and Glade +# find_package(GTK3 3.10 REQUIRED gtk glade) +# +# +# +# :: +# +# Search for GTK/GTKMM 3.8 or later +# find_package(GTK3 3.8 COMPONENTS gtk gtkmm) +# +# +# +# :: +# +# if(GTK3_FOUND) +# include_directories(${GTK3_INCLUDE_DIRS}) +# add_executable(mygui mygui.cc) +# target_link_libraries(mygui ${GTK3_LIBRARIES}) +# endif() + +#============================================================================= +# Copyright 2009 Kitware, Inc. +# Copyright 2008-2012 Philip Lowman +# +# 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.) + +# Version gtk3-0.1 (12/27/2014) +# * Initial port of FindGTK2 (CMake 3.1.0) to FindGTK3. +# sed -i 's/GTK2/GTK3/g +# s/gtk2/gtk3/g +# s,${CMAKE_CURRENT_LIST_DIR}/,,g +# s,.cmake),),g +# s/gtk-x11/gtk/g +# s/gdk-x11/gdk/g +# s/gdkmm-2.4/gdkmm-3.0/g +# s/gtk-2.0/gtk-3.0/g +# s/gtkmm-2.4/gtkmm-3.0/g +# s/2.4;Path/3.0;Path/g +# s,GDKCONFIG gdkconfig.h,GDKCONFIG gdk/gdkconfig.h,g +# s,set(_versions 2,set(_versions 3.0 3 2,g +# s/_gtk_/_gtk3_/g' FindGTK2.cmake +# * Detect cairo-gobject library. +# * Update the dependencies of gdk, gtk, pangomm, gdkmm, gtkmm, glade, and +# glademm based on their .pc files. This ammounts to dropping pangoft2 +# and gthread from the dependencies (they are still detected) while adding +# cairo-gobject. All of the optional dependencies are required in GTK3. +# Version 1.6 (CMake 3.0) +# * Create targets for each library +# * Do not link libfreetype +# Version 1.5 (CMake 2.8.12) +# * 14236: Detect gthread library +# Detect pangocairo on windows +# Detect pangocairo with gtk module instead of with gtkmm +# * 14259: Use vc100 libraries with MSVC11 +# * 14260: Export a GTK2_DEFINITIONS variable to set /vd2 when appropriate +# (i.e. MSVC) +# * Use the optimized/debug syntax for _LIBRARY and _LIBRARIES variables when +# appropriate. A new set of _RELEASE variables was also added. +# * Remove GTK2_SKIP_MARK_AS_ADVANCED option, as now the variables are +# marked as advanced by SelectLibraryConfigurations +# * Detect gmodule, pangoft2 and pangoxft libraries +# Version 1.4 (10/4/2012) (CMake 2.8.10) +# * 12596: Missing paths for FindGTK2 on NetBSD +# * 12049: Fixed detection of GTK include files in the lib folder on +# multiarch systems. +# Version 1.3 (11/9/2010) (CMake 2.8.4) +# * 11429: Add support for detecting GTK2 built with Visual Studio 10. +# Thanks to Vincent Levesque for the patch. +# Version 1.2 (8/30/2010) (CMake 2.8.3) +# * Merge patch for detecting gdk-pixbuf library (split off +# from core GTK in 2.21). Thanks to Vincent Untz for the patch +# and Ricardo Cruz for the heads up. +# Version 1.1 (8/19/2010) (CMake 2.8.3) +# * Add support for detecting GTK2 under macports (thanks to Gary Kramlich) +# Version 1.0 (8/12/2010) (CMake 2.8.3) +# * Add support for detecting new pangommconfig.h header file +# (Thanks to Sune Vuorela & the Debian Project for the patch) +# * Add support for detecting fontconfig.h header +# * Call find_package(Freetype) since it's required +# * Add support for allowing users to add additional library directories +# via the GTK2_ADDITIONAL_SUFFIXES variable (kind of a future-kludge in +# case the GTK developers change versions on any of the directories in the +# future). +# Version 0.8 (1/4/2010) +# * Get module working under MacOSX fink by adding /sw/include, /sw/lib +# to PATHS and the gobject library +# Version 0.7 (3/22/09) +# * Checked into CMake CVS +# * Added versioning support +# * Module now defaults to searching for GTK if COMPONENTS not specified. +# * Added HKCU prior to HKLM registry key and GTKMM specific environment +# variable as per mailing list discussion. +# * Added lib64 to include search path and a few other search paths where GTK +# may be installed on Unix systems. +# * Switched to lowercase CMake commands +# * Prefaced internal variables with _GTK2 to prevent collision +# * Changed internal macros to functions +# * Enhanced documentation +# Version 0.6 (1/8/08) +# Added GTK2_SKIP_MARK_AS_ADVANCED option +# Version 0.5 (12/19/08) +# Second release to cmake mailing list + +#============================================================= +# _GTK3_GET_VERSION +# Internal function to parse the version number in gtkversion.h +# _OUT_major = Major version number +# _OUT_minor = Minor version number +# _OUT_micro = Micro version number +# _gtkversion_hdr = Header file to parse +#============================================================= + +include(SelectLibraryConfigurations) +include(CMakeParseArguments) + +function(_GTK3_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr) + file(STRINGS ${_gtkversion_hdr} _contents REGEX "#define GTK_M[A-Z]+_VERSION[ \t]+") + if(_contents) + string(REGEX REPLACE ".*#define GTK_MAJOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_major} "${_contents}") + string(REGEX REPLACE ".*#define GTK_MINOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_minor} "${_contents}") + string(REGEX REPLACE ".*#define GTK_MICRO_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_micro} "${_contents}") + + if(NOT ${_OUT_major} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for GTK3_MAJOR_VERSION!") + endif() + if(NOT ${_OUT_minor} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for GTK3_MINOR_VERSION!") + endif() + if(NOT ${_OUT_micro} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for GTK3_MICRO_VERSION!") + endif() + + set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE) + set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE) + set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE) + else() + message(FATAL_ERROR "Include file ${_gtkversion_hdr} does not exist") + endif() +endfunction() + +#============================================================= +# _GTK3_FIND_INCLUDE_DIR +# Internal function to find the GTK include directories +# _var = variable to set (_INCLUDE_DIR is appended) +# _hdr = header file to look for +#============================================================= +function(_GTK3_FIND_INCLUDE_DIR _var _hdr) + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK3_FIND_INCLUDE_DIR( ${_var} ${_hdr} )") + endif() + + set(_gtk3_packages + # If these ever change, things will break. + ${GTK3_ADDITIONAL_SUFFIXES} + glibmm-2.4 + glib-2.0 + atk-1.0 + atkmm-1.6 + cairo + cairomm-1.0 + gdk-pixbuf-2.0 + gdkmm-3.0 + giomm-2.4 + gtk-3.0 + gtkmm-3.0 + libglade-2.0 + libglademm-2.4 + pango-1.0 + pangomm-1.4 + sigc++-2.0 + ) + + # + # NOTE: The following suffixes cause searching for header files in both of + # these directories: + # /usr/include/ + # /usr/lib//include + # + + set(_suffixes) + foreach(_d ${_gtk3_packages}) + list(APPEND _suffixes ${_d}) + list(APPEND _suffixes ${_d}/include) # for /usr/lib/gtk-3.0/include + endforeach() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "include suffixes = ${_suffixes}") + endif() + + if(CMAKE_LIBRARY_ARCHITECTURE) + set(_gtk3_arch_dir /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + if(GTK3_DEBUG) + message(STATUS "Adding ${_gtk3_arch_dir} to search path for multiarch support") + endif() + endif() + find_path(GTK3_${_var}_INCLUDE_DIR ${_hdr} + PATHS + ${_gtk3_arch_dir} + /usr/local/lib64 + /usr/local/lib + /usr/lib64 + /usr/lib + /usr/X11R6/include + /usr/X11R6/lib + /opt/gnome/include + /opt/gnome/lib + /opt/openwin/include + /usr/openwin/lib + /sw/include + /sw/lib + /opt/local/include + /opt/local/lib + /usr/pkg/lib + /usr/pkg/include/glib + $ENV{GTKMM_BASEPATH}/include + $ENV{GTKMM_BASEPATH}/lib + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\3.0;Path]/include + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\3.0;Path]/lib + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\3.0;Path]/include + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\3.0;Path]/lib + PATH_SUFFIXES + ${_suffixes} + ) + mark_as_advanced(GTK3_${_var}_INCLUDE_DIR) + + if(GTK3_${_var}_INCLUDE_DIR) + set(GTK3_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS} ${GTK3_${_var}_INCLUDE_DIR} PARENT_SCOPE) + endif() + +endfunction() + +#============================================================= +# _GTK3_FIND_LIBRARY +# Internal function to find libraries packaged with GTK3 +# _var = library variable to create (_LIBRARY is appended) +#============================================================= +function(_GTK3_FIND_LIBRARY _var _lib _expand_vc _append_version) + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK3_FIND_LIBRARY( ${_var} ${_lib} ${_expand_vc} ${_append_version} )") + endif() + + # Not GTK versions per se but the versions encoded into Windows + # import libraries (GtkMM 2.14.1 has a gtkmm-vc80-2_4.lib for example) + # Also the MSVC libraries use _ for . (this is handled below) + set(_versions 3.0 3 2.20 2.18 2.16 2.14 2.12 + 2.10 2.8 2.6 2.4 2.2 2.0 + 1.20 1.18 1.16 1.14 1.12 + 1.10 1.8 1.6 1.4 1.2 1.0) + + set(_library) + set(_library_d) + + set(_library ${_lib}) + + if(_expand_vc AND MSVC) + # Add vc80/vc90/vc100 midfixes + if(MSVC80) + set(_library ${_library}-vc80) + elseif(MSVC90) + set(_library ${_library}-vc90) + elseif(MSVC10) + set(_library ${_library}-vc100) + elseif(MSVC11) + # Up to gtkmm-win 2.22.0-2 there are no vc110 libraries but vc100 can be used + set(_library ${_library}-vc100) + endif() + set(_library_d ${_library}-d) + endif() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "After midfix addition = ${_library} and ${_library_d}") + endif() + + set(_lib_list) + set(_libd_list) + if(_append_version) + foreach(_ver ${_versions}) + list(APPEND _lib_list "${_library}-${_ver}") + list(APPEND _libd_list "${_library_d}-${_ver}") + endforeach() + else() + set(_lib_list ${_library}) + set(_libd_list ${_library_d}) + endif() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "library list = ${_lib_list} and library debug list = ${_libd_list}") + endif() + + # For some silly reason the MSVC libraries use _ instead of . + # in the version fields + if(_expand_vc AND MSVC) + set(_no_dots_lib_list) + set(_no_dots_libd_list) + foreach(_l ${_lib_list}) + string(REPLACE "." "_" _no_dots_library ${_l}) + list(APPEND _no_dots_lib_list ${_no_dots_library}) + endforeach() + # And for debug + set(_no_dots_libsd_list) + foreach(_l ${_libd_list}) + string(REPLACE "." "_" _no_dots_libraryd ${_l}) + list(APPEND _no_dots_libd_list ${_no_dots_libraryd}) + endforeach() + + # Copy list back to original names + set(_lib_list ${_no_dots_lib_list}) + set(_libd_list ${_no_dots_libd_list}) + endif() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "While searching for GTK3_${_var}_LIBRARY, our proposed library list is ${_lib_list}") + endif() + + find_library(GTK3_${_var}_LIBRARY_RELEASE + NAMES ${_lib_list} + PATHS + /opt/gnome/lib + /usr/openwin/lib + /sw/lib + $ENV{GTKMM_BASEPATH}/lib + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\3.0;Path]/lib + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\3.0;Path]/lib + ) + + if(_expand_vc AND MSVC) + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "While searching for GTK3_${_var}_LIBRARY_DEBUG our proposed library list is ${_libd_list}") + endif() + + find_library(GTK3_${_var}_LIBRARY_DEBUG + NAMES ${_libd_list} + PATHS + $ENV{GTKMM_BASEPATH}/lib + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\3.0;Path]/lib + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\3.0;Path]/lib + ) + endif() + + select_library_configurations(GTK3_${_var}) + + set(GTK3_${_var}_LIBRARY ${GTK3_${_var}_LIBRARY} PARENT_SCOPE) + set(GTK3_${_var}_FOUND ${GTK3_${_var}_FOUND} PARENT_SCOPE) + + if(GTK3_${_var}_FOUND) + set(GTK3_LIBRARIES ${GTK3_LIBRARIES} ${GTK3_${_var}_LIBRARY}) + set(GTK3_LIBRARIES ${GTK3_LIBRARIES} PARENT_SCOPE) + endif() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "GTK3_${_var}_LIBRARY_RELEASE = \"${GTK3_${_var}_LIBRARY_RELEASE}\"") + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "GTK3_${_var}_LIBRARY_DEBUG = \"${GTK3_${_var}_LIBRARY_DEBUG}\"") + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "GTK3_${_var}_LIBRARY = \"${GTK3_${_var}_LIBRARY}\"") + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "GTK3_${_var}_FOUND = \"${GTK3_${_var}_FOUND}\"") + endif() + +endfunction() + + +function(_GTK3_ADD_TARGET_DEPENDS_INTERNAL _var _property) + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK3_ADD_TARGET_DEPENDS_INTERNAL( ${_var} ${_property} )") + endif() + + string(TOLOWER "${_var}" _basename) + + if (TARGET GTK3::${_basename}) + foreach(_depend ${ARGN}) + set(_valid_depends) + if (TARGET GTK3::${_depend}) + list(APPEND _valid_depends GTK3::${_depend}) + endif() + if (_valid_depends) + set_property(TARGET GTK3::${_basename} APPEND PROPERTY ${_property} "${_valid_depends}") + endif() + set(_valid_depends) + endforeach() + endif() +endfunction() + +function(_GTK3_ADD_TARGET_DEPENDS _var) + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK3_ADD_TARGET_DEPENDS( ${_var} )") + endif() + + string(TOLOWER "${_var}" _basename) + + if(TARGET GTK3::${_basename}) + get_target_property(_configs GTK3::${_basename} IMPORTED_CONFIGURATIONS) + _GTK3_ADD_TARGET_DEPENDS_INTERNAL(${_var} INTERFACE_LINK_LIBRARIES ${ARGN}) + foreach(_config ${_configs}) + _GTK3_ADD_TARGET_DEPENDS_INTERNAL(${_var} IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} ${ARGN}) + endforeach() + endif() +endfunction() + +function(_GTK3_ADD_TARGET_INCLUDE_DIRS _var) + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK3_ADD_TARGET_INCLUDE_DIRS( ${_var} )") + endif() + + string(TOLOWER "${_var}" _basename) + + if(TARGET GTK3::${_basename}) + foreach(_include ${ARGN}) + set_property(TARGET GTK3::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_include}") + endforeach() + endif() +endfunction() + +#============================================================= +# _GTK3_ADD_TARGET +# Internal function to create targets for GTK3 +# _var = target to create +#============================================================= +function(_GTK3_ADD_TARGET _var) + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK3_ADD_TARGET( ${_var} )") + endif() + + string(TOLOWER "${_var}" _basename) + + cmake_parse_arguments(_${_var} "" "" "GTK3_DEPENDS;GTK3_OPTIONAL_DEPENDS;OPTIONAL_INCLUDES" ${ARGN}) + + if(GTK3_${_var}_FOUND AND NOT TARGET GTK3::${_basename}) + # Do not create the target if dependencies are missing + foreach(_dep ${_${_var}_GTK3_DEPENDS}) + if(NOT TARGET GTK3::${_dep}) + return() + endif() + endforeach() + + add_library(GTK3::${_basename} UNKNOWN IMPORTED) + + if(GTK3_${_var}_LIBRARY_RELEASE) + set_property(TARGET GTK3::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_property(TARGET GTK3::${_basename} PROPERTY IMPORTED_LOCATION_RELEASE "${GTK3_${_var}_LIBRARY_RELEASE}" ) + endif() + + if(GTK3_${_var}_LIBRARY_DEBUG) + set_property(TARGET GTK3::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_property(TARGET GTK3::${_basename} PROPERTY IMPORTED_LOCATION_DEBUG "${GTK3_${_var}_LIBRARY_DEBUG}" ) + endif() + + if(GTK3_${_var}_INCLUDE_DIR) + set_property(TARGET GTK3::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK3_${_var}_INCLUDE_DIR}") + endif() + + if(GTK3_${_var}CONFIG_INCLUDE_DIR AND NOT "x${GTK3_${_var}CONFIG_INCLUDE_DIR}" STREQUAL "x${GTK3_${_var}_INCLUDE_DIR}") + set_property(TARGET GTK3::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK3_${_var}CONFIG_INCLUDE_DIR}") + endif() + + if(GTK3_DEFINITIONS) + set_property(TARGET GTK3::${_basename} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${GTK3_DEFINITIONS}") + endif() + + if(_${_var}_GTK3_DEPENDS) + _GTK3_ADD_TARGET_DEPENDS(${_var} ${_${_var}_GTK3_DEPENDS} ${_${_var}_GTK3_OPTIONAL_DEPENDS}) + endif() + + if(_${_var}_OPTIONAL_INCLUDES) + foreach(_D ${_${_var}_OPTIONAL_INCLUDES}) + if(_D) + _GTK3_ADD_TARGET_INCLUDE_DIRS(${_var} ${_D}) + endif() + endforeach() + endif() + + if(GTK3_USE_IMPORTED_TARGETS) + set(GTK3_${_var}_LIBRARY GTK3::${_basename} PARENT_SCOPE) + endif() + + endif() +endfunction() + + + +#============================================================= + +# +# main() +# + +set(GTK3_FOUND) +set(GTK3_INCLUDE_DIRS) +set(GTK3_LIBRARIES) +set(GTK3_DEFINITIONS) + +if(NOT GTK3_FIND_COMPONENTS) + # Assume they only want GTK + set(GTK3_FIND_COMPONENTS gtk) +endif() + +# +# If specified, enforce version number +# +if(GTK3_FIND_VERSION) + set(GTK3_FAILED_VERSION_CHECK true) + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "Searching for version ${GTK3_FIND_VERSION}") + endif() + _GTK3_FIND_INCLUDE_DIR(GTK gtk/gtk.h) + if(GTK3_GTK_INCLUDE_DIR) + _GTK3_GET_VERSION(GTK3_MAJOR_VERSION + GTK3_MINOR_VERSION + GTK3_PATCH_VERSION + ${GTK3_GTK_INCLUDE_DIR}/gtk/gtkversion.h) + set(GTK3_VERSION + ${GTK3_MAJOR_VERSION}.${GTK3_MINOR_VERSION}.${GTK3_PATCH_VERSION}) + if(GTK3_FIND_VERSION_EXACT) + if(GTK3_VERSION VERSION_EQUAL GTK3_FIND_VERSION) + set(GTK3_FAILED_VERSION_CHECK false) + endif() + else() + if(GTK3_VERSION VERSION_EQUAL GTK3_FIND_VERSION OR + GTK3_VERSION VERSION_GREATER GTK3_FIND_VERSION) + set(GTK3_FAILED_VERSION_CHECK false) + endif() + endif() + else() + # If we can't find the GTK include dir, we can't do version checking + if(GTK3_FIND_REQUIRED AND NOT GTK3_FIND_QUIETLY) + message(FATAL_ERROR "Could not find GTK3 include directory") + endif() + return() + endif() + + if(GTK3_FAILED_VERSION_CHECK) + if(GTK3_FIND_REQUIRED AND NOT GTK3_FIND_QUIETLY) + if(GTK3_FIND_VERSION_EXACT) + message(FATAL_ERROR "GTK3 version check failed. Version ${GTK3_VERSION} was found, version ${GTK3_FIND_VERSION} is needed exactly.") + else() + message(FATAL_ERROR "GTK3 version check failed. Version ${GTK3_VERSION} was found, at least version ${GTK3_FIND_VERSION} is required") + endif() + endif() + + # If the version check fails, exit out of the module here + return() + endif() +endif() + +# +# On MSVC, according to https://wiki.gnome.org/gtkmm/MSWindows, the /vd2 flag needs to be +# passed to the compiler in order to use gtkmm +# +if(MSVC) + foreach(_GTK3_component ${GTK3_FIND_COMPONENTS}) + if(_GTK3_component STREQUAL "gtkmm") + set(GTK3_DEFINITIONS "/vd2") + elseif(_GTK3_component STREQUAL "glademm") + set(GTK3_DEFINITIONS "/vd2") + endif() + endforeach() +endif() + +# +# Find all components +# + +find_package(Freetype QUIET) +if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) + list(APPEND GTK3_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) +endif() + +foreach(_GTK3_component ${GTK3_FIND_COMPONENTS}) + if(_GTK3_component STREQUAL "gtk") + # Left for compatibility with previous versions. + _GTK3_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h) + _GTK3_FIND_INCLUDE_DIR(X11 X11/Xlib.h) + + _GTK3_FIND_INCLUDE_DIR(GLIB glib.h) + _GTK3_FIND_INCLUDE_DIR(GLIBCONFIG glibconfig.h) + _GTK3_FIND_LIBRARY (GLIB glib false true) + _GTK3_ADD_TARGET (GLIB) + + _GTK3_FIND_INCLUDE_DIR(GOBJECT glib-object.h) + _GTK3_FIND_LIBRARY (GOBJECT gobject false true) + _GTK3_ADD_TARGET (GOBJECT GTK3_DEPENDS glib) + + _GTK3_FIND_INCLUDE_DIR(ATK atk/atk.h) + _GTK3_FIND_LIBRARY (ATK atk false true) + _GTK3_ADD_TARGET (ATK GTK3_DEPENDS gobject glib) + + _GTK3_FIND_LIBRARY (GIO gio false true) + _GTK3_ADD_TARGET (GIO GTK3_DEPENDS gobject glib) + + _GTK3_FIND_LIBRARY (GTHREAD gthread false true) + _GTK3_ADD_TARGET (GTHREAD GTK3_DEPENDS glib) + + _GTK3_FIND_LIBRARY (GMODULE gmodule false true) + _GTK3_ADD_TARGET (GMODULE GTK3_DEPENDS glib) + + _GTK3_FIND_INCLUDE_DIR(GDK_PIXBUF gdk-pixbuf/gdk-pixbuf.h) + _GTK3_FIND_LIBRARY (GDK_PIXBUF gdk_pixbuf false true) + _GTK3_ADD_TARGET (GDK_PIXBUF GTK3_DEPENDS gobject glib) + + _GTK3_FIND_INCLUDE_DIR(CAIRO cairo.h) + _GTK3_FIND_LIBRARY (CAIRO cairo false false) + _GTK3_ADD_TARGET (CAIRO) + + _GTK3_FIND_INCLUDE_DIR(CAIRO_GOBJECT cairo-gobject.h) + _GTK3_FIND_LIBRARY (CAIRO_GOBJECT cairo-gobject false false) + _GTK3_ADD_TARGET (CAIRO_GOBJECT GTK3_DEPENDS cairo gobject glib) + + _GTK3_FIND_INCLUDE_DIR(PANGO pango/pango.h) + _GTK3_FIND_LIBRARY (PANGO pango false true) + _GTK3_ADD_TARGET (PANGO GTK3_DEPENDS gobject glib) + + _GTK3_FIND_LIBRARY (PANGOCAIRO pangocairo false true) + _GTK3_ADD_TARGET (PANGOCAIRO GTK3_DEPENDS pango cairo gobject glib) + + _GTK3_FIND_LIBRARY (PANGOFT2 pangoft2 false true) + _GTK3_ADD_TARGET (PANGOFT2 GTK3_DEPENDS pango gobject glib + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK3_FONTCONFIG_INCLUDE_DIR} + ${GTK3_X11_INCLUDE_DIR}) + + _GTK3_FIND_LIBRARY (PANGOXFT pangoxft false true) + _GTK3_ADD_TARGET (PANGOXFT GTK3_DEPENDS pangoft2 pango gobject glib + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK3_FONTCONFIG_INCLUDE_DIR} + ${GTK3_X11_INCLUDE_DIR}) + + _GTK3_FIND_INCLUDE_DIR(GDK gdk/gdk.h) + _GTK3_FIND_INCLUDE_DIR(GDKCONFIG gdk/gdkconfig.h) + if(UNIX) + if(APPLE) + _GTK3_FIND_LIBRARY (GDK gdk-quartz false true) + endif() + if(NOT GTK3_GDK_FOUND) + _GTK3_FIND_LIBRARY (GDK gdk false true) + endif() + else() + _GTK3_FIND_LIBRARY (GDK gdk-win32 false true) + endif() + _GTK3_ADD_TARGET (GDK GTK3_DEPENDS pangocairo pango cairo-gobject cairo gdk_pixbuf gobject glib) + + _GTK3_FIND_INCLUDE_DIR(GTK gtk/gtk.h) + if(UNIX) + if(APPLE) + _GTK3_FIND_LIBRARY (GTK gtk-quartz false true) + endif() + if(NOT GTK3_GTK_FOUND) + _GTK3_FIND_LIBRARY (GTK gtk false true) + endif() + else() + _GTK3_FIND_LIBRARY (GTK gtk-win32 false true) + endif() + _GTK3_ADD_TARGET (GTK GTK3_DEPENDS gdk atk pangocairo pango cairo-gobject cairo gdk_pixbuf gio gobject glib) + + elseif(_GTK3_component STREQUAL "gtkmm") + + _GTK3_FIND_INCLUDE_DIR(SIGC++ sigc++/sigc++.h) + _GTK3_FIND_INCLUDE_DIR(SIGC++CONFIG sigc++config.h) + _GTK3_FIND_LIBRARY (SIGC++ sigc true true) + _GTK3_ADD_TARGET (SIGC++) + + _GTK3_FIND_INCLUDE_DIR(GLIBMM glibmm.h) + _GTK3_FIND_INCLUDE_DIR(GLIBMMCONFIG glibmmconfig.h) + _GTK3_FIND_LIBRARY (GLIBMM glibmm true true) + _GTK3_ADD_TARGET (GLIBMM GTK3_DEPENDS gobject sigc++ glib) + + _GTK3_FIND_INCLUDE_DIR(GIOMM giomm.h) + _GTK3_FIND_INCLUDE_DIR(GIOMMCONFIG giommconfig.h) + _GTK3_FIND_LIBRARY (GIOMM giomm true true) + _GTK3_ADD_TARGET (GIOMM GTK3_DEPENDS gio glibmm gobject sigc++ glib) + + _GTK3_FIND_INCLUDE_DIR(ATKMM atkmm.h) + _GTK3_FIND_LIBRARY (ATKMM atkmm true true) + _GTK3_ADD_TARGET (ATKMM GTK3_DEPENDS atk glibmm gobject sigc++ glib) + + _GTK3_FIND_INCLUDE_DIR(CAIROMM cairomm/cairomm.h) + _GTK3_FIND_INCLUDE_DIR(CAIROMMCONFIG cairommconfig.h) + _GTK3_FIND_LIBRARY (CAIROMM cairomm true true) + _GTK3_ADD_TARGET (CAIROMM GTK3_DEPENDS cairo sigc++ + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK3_FONTCONFIG_INCLUDE_DIR} + ${GTK3_X11_INCLUDE_DIR}) + + _GTK3_FIND_INCLUDE_DIR(PANGOMM pangomm.h) + _GTK3_FIND_INCLUDE_DIR(PANGOMMCONFIG pangommconfig.h) + _GTK3_FIND_LIBRARY (PANGOMM pangomm true true) + _GTK3_ADD_TARGET (PANGOMM GTK3_DEPENDS glibmm cairomm sigc++ pangocairo pango cairo gobject glib + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK3_FONTCONFIG_INCLUDE_DIR} + ${GTK3_X11_INCLUDE_DIR}) + + _GTK3_FIND_INCLUDE_DIR(GDKMM gdkmm.h) + _GTK3_FIND_INCLUDE_DIR(GDKMMCONFIG gdkmmconfig.h) + _GTK3_FIND_LIBRARY (GDKMM gdkmm true true) + _GTK3_ADD_TARGET (GDKMM GTK3_DEPENDS pangomm giomm glibmm cairomm sigc++ gtk gdk atk pangocairo pango cairo-gobject cairo gdk_pixbuf gio gobject glib + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK3_FONTCONFIG_INCLUDE_DIR} + ${GTK3_X11_INCLUDE_DIR}) + + _GTK3_FIND_INCLUDE_DIR(GTKMM gtkmm.h) + _GTK3_FIND_INCLUDE_DIR(GTKMMCONFIG gtkmmconfig.h) + _GTK3_FIND_LIBRARY (GTKMM gtkmm true true) + _GTK3_ADD_TARGET (GTKMM GTK3_DEPENDS atkmm gdkmm pangomm giomm glibmm cairomm sigc++ gtk gdk atk pangocairo pango cairo-gobject cairo gdk_pixbuf gio gobject glib + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK3_FONTCONFIG_INCLUDE_DIR} + ${GTK3_X11_INCLUDE_DIR}) + + elseif(_GTK3_component STREQUAL "glade") + + _GTK3_FIND_INCLUDE_DIR(GLADE glade/glade.h) + _GTK3_FIND_LIBRARY (GLADE glade false true) + _GTK3_ADD_TARGET (GLADE GTK3_DEPENDS gtk gdk atk pangocairo pango cairo-gobject cairo gdk_pixbuf gio gobject glib + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK3_FONTCONFIG_INCLUDE_DIR} + ${GTK3_X11_INCLUDE_DIR}) + + elseif(_GTK3_component STREQUAL "glademm") + + _GTK3_FIND_INCLUDE_DIR(GLADEMM libglademm.h) + _GTK3_FIND_INCLUDE_DIR(GLADEMMCONFIG libglademmconfig.h) + _GTK3_FIND_LIBRARY (GLADEMM glademm true true) + _GTK3_ADD_TARGET (GLADEMM GTK3_DEPENDS gtkmm glade atkmm gdkmm pangomm giomm glibmm cairomm sigc++ gtk gdk atk pangocairo pango cairo-gobject cairo gdk_pixbuf gio gobject glib + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK3_FONTCONFIG_INCLUDE_DIR} + ${GTK3_X11_INCLUDE_DIR}) + + else() + message(FATAL_ERROR "Unknown GTK3 component ${_component}") + endif() +endforeach() + +# +# Solve for the GTK3 version if we haven't already +# +if(NOT GTK3_FIND_VERSION AND GTK3_GTK_INCLUDE_DIR) + _GTK3_GET_VERSION(GTK3_MAJOR_VERSION + GTK3_MINOR_VERSION + GTK3_PATCH_VERSION + ${GTK3_GTK_INCLUDE_DIR}/gtk/gtkversion.h) + set(GTK3_VERSION ${GTK3_MAJOR_VERSION}.${GTK3_MINOR_VERSION}.${GTK3_PATCH_VERSION}) +endif() + +# +# Try to enforce components +# + +set(_GTK3_did_we_find_everything true) # This gets set to GTK3_FOUND + +include(FindPackageHandleStandardArgs) + +foreach(_GTK3_component ${GTK3_FIND_COMPONENTS}) + string(TOUPPER ${_GTK3_component} _COMPONENT_UPPER) + + set(GTK3_${_COMPONENT_UPPER}_FIND_QUIETLY ${GTK3_FIND_QUIETLY}) + + if(_GTK3_component STREQUAL "gtk") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3_${_COMPONENT_UPPER} "Some or all of the gtk libraries were not found." + GTK3_GTK_LIBRARY + GTK3_GTK_INCLUDE_DIR + + GTK3_GDK_INCLUDE_DIR + GTK3_GDKCONFIG_INCLUDE_DIR + GTK3_GDK_LIBRARY + + GTK3_GLIB_INCLUDE_DIR + GTK3_GLIBCONFIG_INCLUDE_DIR + GTK3_GLIB_LIBRARY + ) + elseif(_GTK3_component STREQUAL "gtkmm") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3_${_COMPONENT_UPPER} "Some or all of the gtkmm libraries were not found." + GTK3_GTKMM_LIBRARY + GTK3_GTKMM_INCLUDE_DIR + GTK3_GTKMMCONFIG_INCLUDE_DIR + + GTK3_GDKMM_INCLUDE_DIR + GTK3_GDKMMCONFIG_INCLUDE_DIR + GTK3_GDKMM_LIBRARY + + GTK3_GLIBMM_INCLUDE_DIR + GTK3_GLIBMMCONFIG_INCLUDE_DIR + GTK3_GLIBMM_LIBRARY + + FREETYPE_INCLUDE_DIR_ft2build + FREETYPE_INCLUDE_DIR_freetype2 + ) + elseif(_GTK3_component STREQUAL "glade") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3_${_COMPONENT_UPPER} "The glade library was not found." + GTK3_GLADE_LIBRARY + GTK3_GLADE_INCLUDE_DIR + ) + elseif(_GTK3_component STREQUAL "glademm") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3_${_COMPONENT_UPPER} "The glademm library was not found." + GTK3_GLADEMM_LIBRARY + GTK3_GLADEMM_INCLUDE_DIR + GTK3_GLADEMMCONFIG_INCLUDE_DIR + ) + endif() + + if(NOT GTK3_${_COMPONENT_UPPER}_FOUND) + set(_GTK3_did_we_find_everything false) + endif() +endforeach() + +if(_GTK3_did_we_find_everything AND NOT GTK3_VERSION_CHECK_FAILED) + set(GTK3_FOUND true) +else() + # Unset our variables. + set(GTK3_FOUND false) + set(GTK3_VERSION) + set(GTK3_VERSION_MAJOR) + set(GTK3_VERSION_MINOR) + set(GTK3_VERSION_PATCH) + set(GTK3_INCLUDE_DIRS) + set(GTK3_LIBRARIES) + set(GTK3_DEFINITIONS) +endif() + +if(GTK3_INCLUDE_DIRS) + list(REMOVE_DUPLICATES GTK3_INCLUDE_DIRS) +endif() + diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 88c9b1cdb4..0e950c0799 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -39,7 +39,7 @@ check_lib(PORTAUDIO portaudio portaudio.h pa_linux_alsa.h) check_lib(SOUNDTOUCH SoundTouch soundtouch/SoundTouch.h) if(SDL2_API) - check_lib(SDL2 SDL2 SDL.h) + check_lib(SDL2 SDL2-2.0 SDL.h PATH_SUFFIXES include/SDL2) else() # Tell cmake that we use SDL as a library and not as an application set(SDL_BUILDING_LIBRARY TRUE) @@ -50,7 +50,11 @@ if (Linux) find_package(X11) # Most plugins (if not all) and PCSX2 core need gtk2, so set the required flags if (GTK3_API) - check_lib(GTK3 gtk+-3.0 gtk/gtk.h) + if(CMAKE_CROSSCOMPILING) + find_package(GTK3 REQUIRED gtk) + else() + check_lib(GTK3 gtk+-3.0 gtk/gtk.h) + endif() else() find_package(GTK2 REQUIRED gtk) endif() From c8c22cf6a0e593cda9227bc8f80d31f9ffaaea75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Sun, 28 Dec 2014 01:41:57 -0500 Subject: [PATCH 09/11] Notify about cross build option upon failure. Tell the user to use CMAKE_TOOLCHAIN_FILE upon failure. . Cleanup detectOperatingSystem. Should be the same but adding GNU and kFreeBSD from Debian and filtering out pre OS X Apple. . libaio is linux only. Also check for the correct header since aio.h is the POSIX one. Both are in /usr/include/ anyway. Only build core if (Linux AND NOT AIO_FOUND) == false. . Use Unix for GTK and X11. Macs has gtk-quartzs and xquartz or native X11. *BSD, linux, etc should have both. --- cmake/BuildParameters.cmake | 6 +++- cmake/Pcsx2Utils.cmake | 62 +++++++++++++++------------------- cmake/SearchForStuff.cmake | 8 +++-- cmake/SelectPcsx2Plugins.cmake | 4 +-- plugins/zerogs/CMakeLists.txt | 2 +- 5 files changed, 40 insertions(+), 42 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 88db4daf92..6ba47f6f9f 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -80,7 +80,11 @@ include(TargetArch) target_architecture(PCSX2_TARGET_ARCHITECTURES) if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64" OR ${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64" AND (CMAKE_BUILD_TYPE MATCHES "Release" OR PACKAGE_MODE)) - message(FATAL_ERROR "The code for ${PCSX2_TARGET_ARCHITECTURES} support is not ready yet.") + message(FATAL_ERROR " + The code for ${PCSX2_TARGET_ARCHITECTURES} support is not ready yet. + For now compile with -DCMAKE_TOOLCHAIN_FILE=cmake/linux-compiler-i386-multilib.cmake + or with + --cross-multilib passed to build.sh") endif() message(STATUS "Compiling a ${PCSX2_TARGET_ARCHITECTURES} build on a ${CMAKE_HOST_SYSTEM_PROCESSOR} host.") else() diff --git a/cmake/Pcsx2Utils.cmake b/cmake/Pcsx2Utils.cmake index f0557b2cd4..00dc841d57 100644 --- a/cmake/Pcsx2Utils.cmake +++ b/cmake/Pcsx2Utils.cmake @@ -7,42 +7,34 @@ # On linux, it also set a flag for specific distribution (ie Fedora) #------------------------------------------------------------------------------- function(detectOperatingSystem) - # nothing detected yet - set(MacOSX FALSE PARENT_SCOPE) - set(Windows FALSE PARENT_SCOPE) - set(Linux FALSE PARENT_SCOPE) - set(Fedora FALSE PARENT_SCOPE) - - # check if we are on Linux - if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - set(Linux TRUE PARENT_SCOPE) - - if (EXISTS /etc/os-release) - # Read the file without CR character - file(STRINGS /etc/os-release OS_RELEASE) - if ("${OS_RELEASE}" MATCHES "^.*ID=fedora.*$") - set(Fedora TRUE PARENT_SCOPE) - message(STATUS "Build Fedora specific") - endif() - if ("${OS_RELEASE}" MATCHES "^.*ID=.*suse.*$") - set(openSUSE TRUE PARENT_SCOPE) - add_definitions(-DopenSUSE) - message(STATUS "Build openSUSE specific") - endif() - endif() - endif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - - # check if we are on MacOSX - if(APPLE) - message(WARNING "Mac OS X isn't supported, build will most likely fail") - set(MacOSX TRUE PARENT_SCOPE) - endif(APPLE) - - # check if we are on Windows - if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + if(WIN32) set(Windows TRUE PARENT_SCOPE) - endif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") -endfunction(detectOperatingSystem) + elseif(UNIX AND APPLE) + # No easy way to filter out iOS. + message(WARNING "OS X/iOS isn't supported, the build will most likely fail") + set(MacOSX TRUE PARENT_SCOPE) + elseif(UNIX) + if(CMAKE_SYSTEM_NAME MATCHES "Linux") + set(Linux TRUE PARENT_SCOPE) + if (EXISTS /etc/os-release) + # Read the file without CR character + file(STRINGS /etc/os-release OS_RELEASE) + if("${OS_RELEASE}" MATCHES "^.*ID=fedora.*$") + set(Fedora TRUE PARENT_SCOPE) + message(STATUS "Build Fedora specific") + elseif("${OS_RELEASE}" MATCHES "^.*ID=.*suse.*$") + set(openSUSE TRUE PARENT_SCOPE) + add_definitions(-DopenSUSE) + message(STATUS "Build openSUSE specific") + endif() + endif() + elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD") + set(kFreeBSD TRUE PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "GNU") + set(GNU TRUE PARENT_SCOPE) + endif() + endif() +endfunction() function(write_svnrev_h) find_package(Git) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 0e950c0799..9b3cfd37bd 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -32,7 +32,9 @@ include(FindLibc) ## Use CheckLib package to find module include(CheckLib) -check_lib(AIO aio aio.h) +if(Linux) + check_lib(AIO aio libaio.h) +endif() check_lib(EGL EGL EGL/egl.h) check_lib(GLESV2 GLESv2 GLES3/gl3ext.h) # NOTE: looking for GLESv3, not GLESv2 check_lib(PORTAUDIO portaudio portaudio.h pa_linux_alsa.h) @@ -46,7 +48,7 @@ else() find_package(SDL) endif() -if (Linux) +if(UNIX) find_package(X11) # Most plugins (if not all) and PCSX2 core need gtk2, so set the required flags if (GTK3_API) @@ -63,7 +65,7 @@ endif() #---------------------------------------- # Use system include #---------------------------------------- -if(Linux) +if(UNIX) if(GTK2_FOUND) include_directories(${GTK2_INCLUDE_DIRS}) elseif(GTK3_FOUND) diff --git a/cmake/SelectPcsx2Plugins.cmake b/cmake/SelectPcsx2Plugins.cmake index 70cfc63a0c..b4f7f11af5 100644 --- a/cmake/SelectPcsx2Plugins.cmake +++ b/cmake/SelectPcsx2Plugins.cmake @@ -56,7 +56,7 @@ endif() # -aio #--------------------------------------- # Common dependancy -if(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs AND AIO_FOUND) +if(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs AND NOT (Linux AND NOT AIO_FOUND)) set(pcsx2_core TRUE) elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/pcsx2") set(pcsx2_core FALSE) @@ -66,7 +66,7 @@ else() message(STATUS "${msg_dep_pcsx2}") endif() # Linux need also gtk2 -if(Linux AND pcsx2_core AND NOT GTKn_FOUND) +if(UNIX AND pcsx2_core AND NOT GTKn_FOUND) set(pcsx2_core FALSE) message(STATUS "Skip build of pcsx2 core: miss some dependencies") message(STATUS "${msg_dep_pcsx2}") diff --git a/plugins/zerogs/CMakeLists.txt b/plugins/zerogs/CMakeLists.txt index 1afb1cfa8e..983441e079 100644 --- a/plugins/zerogs/CMakeLists.txt +++ b/plugins/zerogs/CMakeLists.txt @@ -4,4 +4,4 @@ # zerogs plugin opengl if(UNIX) add_subdirectory(opengl) -endif(UNIX) +endif() From be1842f4e9f4d858b33645605ae5eadc6f86359e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Sun, 28 Dec 2014 04:05:22 -0500 Subject: [PATCH 10/11] Detect clang and automatically set USE_CLANG. User may forget or not know about -DUSE_CLANG=TRUE. It could probably be always autodetected instead of requiring user input. . Trivial wording changes to compiler_version. --- cmake/BuildParameters.cmake | 5 +++++ cmake/Pcsx2Utils.cmake | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 6ba47f6f9f..82d52401d8 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -63,6 +63,11 @@ endif() option(USE_CLANG "Use llvm/clang to build PCSX2 (developer option)") option(USE_ASAN "Enable address sanitizer") +# It's probably better to autodetect the USE_CLANG. Remove the option? +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT USE_CLANG) + set(USE_CLANG TRUE) +endif() + #------------------------------------------------------------------------------- # Select the architecture #------------------------------------------------------------------------------- diff --git a/cmake/Pcsx2Utils.cmake b/cmake/Pcsx2Utils.cmake index 00dc841d57..91f18fc019 100644 --- a/cmake/Pcsx2Utils.cmake +++ b/cmake/Pcsx2Utils.cmake @@ -54,16 +54,16 @@ function(write_svnrev_h) endfunction() function(check_compiler_version version_warn version_err) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + if(CMAKE_COMPILER_IS_GNUCXX) execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) string(STRIP "${GCC_VERSION}" GCC_VERSION) if(GCC_VERSION VERSION_LESS ${version_err}) - message(FATAL_ERROR "PCSX2 doesn't support your old GCC ${GCC_VERSION}! Please upgrade it ! + message(FATAL_ERROR "PCSX2 doesn't support your old GCC ${GCC_VERSION}! Please upgrade it! - The minimum version is ${version_err} but ${version_warn} is warmly recommended") + The minimum supported version is ${version_err} but ${version_warn} is warmly recommended") else() if(GCC_VERSION VERSION_LESS ${version_warn}) - message(WARNING "PCSX2 will stop to support GCC ${GCC_VERSION} in a near future. Please upgrade it to GCC ${version_warn}.") + message(WARNING "PCSX2 will stop supporting GCC ${GCC_VERSION} in the near future. Please upgrade to at least GCC ${version_warn}.") endif() endif() endif() From c2cba0d4ae984347e2c6e0e9c8cfc4381082fd3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Sun, 28 Dec 2014 12:54:17 -0500 Subject: [PATCH 11/11] Quick regression fix for SDL2 detection. I only had to add "PATH_SUFFIXES SDL2". . include is superfluous SDL2-2.0 is a distro specific convenience symlink. Use the correct one as before. . I probably did this as an artificial way of disabling pkgconfig when cross compiling and before disabling pkgconfig for all cross compiling but it's wrong. I thought I had fixed this already. --- cmake/SearchForStuff.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 9b3cfd37bd..5e3d0278ab 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -41,7 +41,7 @@ check_lib(PORTAUDIO portaudio portaudio.h pa_linux_alsa.h) check_lib(SOUNDTOUCH SoundTouch soundtouch/SoundTouch.h) if(SDL2_API) - check_lib(SDL2 SDL2-2.0 SDL.h PATH_SUFFIXES include/SDL2) + check_lib(SDL2 SDL2 SDL.h PATH_SUFFIXES SDL2) else() # Tell cmake that we use SDL as a library and not as an application set(SDL_BUILDING_LIBRARY TRUE)