oxen-core/cmake/32-bit-toolchain.cmake

49 lines
2.2 KiB
CMake
Raw Normal View History

2018-01-07 06:05:16 +01:00
# Copyright (c) 2014-2018, The Monero Project
#
# 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.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Static builds: make usable binaries from cmake This adds a static dependency script for libraries like boost, unbound, etc. to cmake, invokable with: cmake .. -DBUILD_STATIC_DEPS=ON which downloads and builds static versions of all our required dependencies (boost, unbound, openssl, ncurses, etc.). It also implies -DSTATIC=ON to build other vendored deps (like miniupnpc, lokimq) as static as well. Unlike the contrib/depends system, this is easier to maintain (one script using nicer cmake with functions instead of raw Makefile spaghetti code), and isn't concerned with reproducible builds -- this doesn't rebuild the compiler, for instance. It also works with the existing build system so that it is simply another way to invoke the cmake build scripts but doesn't require any external tooling. This works on Linux, Mac, and Windows. Some random comments on this commit (for preserving history): - Don't use target_link_libraries on imported targets. Newer cmake is fine with it, but Bionic's cmake doesn't like it but seems okay with setting the properties directly. - This rebuilds libzmq and libsodium, even though there is some provision already within loki-core to do so: however, the existing embedded libzmq fails with the static deps because it uses libzmq's cmake build script, which relies on pkg-config to find libsodium which ends up finding the system one (or not finding any), rather than the one we build with DownloadLibSodium. Since both libsodium and libzmq are faily simple builds it seemed easiest to just add them to the cmake static build rather than trying to shoehorn the current code into the static build script. - Half of the protobuf build system ignores CC/CXX just because Google, and there's no documentation anywhere except for a random closed bug report about needing to set these other variables (CC_FOR_BUILD, CXX_FOR_BUILD) instead, but you need to. Thanks Google. - The boost build is set to output very little because even the minimum -d1 output level spams ~15k lines of output just for the headers it installs.
2020-06-11 20:19:44 +02:00
if(NOT CMAKE_HOST_WIN32)
set(CMAKE_SYSTEM_NAME Windows)
endif()
2014-08-06 19:13:06 +02:00
Static builds: make usable binaries from cmake This adds a static dependency script for libraries like boost, unbound, etc. to cmake, invokable with: cmake .. -DBUILD_STATIC_DEPS=ON which downloads and builds static versions of all our required dependencies (boost, unbound, openssl, ncurses, etc.). It also implies -DSTATIC=ON to build other vendored deps (like miniupnpc, lokimq) as static as well. Unlike the contrib/depends system, this is easier to maintain (one script using nicer cmake with functions instead of raw Makefile spaghetti code), and isn't concerned with reproducible builds -- this doesn't rebuild the compiler, for instance. It also works with the existing build system so that it is simply another way to invoke the cmake build scripts but doesn't require any external tooling. This works on Linux, Mac, and Windows. Some random comments on this commit (for preserving history): - Don't use target_link_libraries on imported targets. Newer cmake is fine with it, but Bionic's cmake doesn't like it but seems okay with setting the properties directly. - This rebuilds libzmq and libsodium, even though there is some provision already within loki-core to do so: however, the existing embedded libzmq fails with the static deps because it uses libzmq's cmake build script, which relies on pkg-config to find libsodium which ends up finding the system one (or not finding any), rather than the one we build with DownloadLibSodium. Since both libsodium and libzmq are faily simple builds it seemed easiest to just add them to the cmake static build rather than trying to shoehorn the current code into the static build script. - Half of the protobuf build system ignores CC/CXX just because Google, and there's no documentation anywhere except for a random closed bug report about needing to set these other variables (CC_FOR_BUILD, CXX_FOR_BUILD) instead, but you need to. Thanks Google. - The boost build is set to output very little because even the minimum -d1 output level spams ~15k lines of output just for the headers it installs.
2020-06-11 20:19:44 +02:00
set(ARCH_TRIPLET i686-w64-mingw32)
set(CMAKE_C_COMPILER ${ARCH_TRIPLET}-gcc-posix)
set(CMAKE_CXX_COMPILER ${ARCH_TRIPLET}-g++-posix)
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
set(CMAKE_NM nm CACHE FILEPATH "" FORCE)
set(CMAKE_LINKER ld CACHE FILEPATH "" FORCE)
set(CMAKE_RC_COMPILER ${ARCH_TRIPLET}-windres)
2014-08-06 19:13:06 +02:00
Static builds: make usable binaries from cmake This adds a static dependency script for libraries like boost, unbound, etc. to cmake, invokable with: cmake .. -DBUILD_STATIC_DEPS=ON which downloads and builds static versions of all our required dependencies (boost, unbound, openssl, ncurses, etc.). It also implies -DSTATIC=ON to build other vendored deps (like miniupnpc, lokimq) as static as well. Unlike the contrib/depends system, this is easier to maintain (one script using nicer cmake with functions instead of raw Makefile spaghetti code), and isn't concerned with reproducible builds -- this doesn't rebuild the compiler, for instance. It also works with the existing build system so that it is simply another way to invoke the cmake build scripts but doesn't require any external tooling. This works on Linux, Mac, and Windows. Some random comments on this commit (for preserving history): - Don't use target_link_libraries on imported targets. Newer cmake is fine with it, but Bionic's cmake doesn't like it but seems okay with setting the properties directly. - This rebuilds libzmq and libsodium, even though there is some provision already within loki-core to do so: however, the existing embedded libzmq fails with the static deps because it uses libzmq's cmake build script, which relies on pkg-config to find libsodium which ends up finding the system one (or not finding any), rather than the one we build with DownloadLibSodium. Since both libsodium and libzmq are faily simple builds it seemed easiest to just add them to the cmake static build rather than trying to shoehorn the current code into the static build script. - Half of the protobuf build system ignores CC/CXX just because Google, and there's no documentation anywhere except for a random closed bug report about needing to set these other variables (CC_FOR_BUILD, CXX_FOR_BUILD) instead, but you need to. Thanks Google. - The boost build is set to output very little because even the minimum -d1 output level spams ~15k lines of output just for the headers it installs.
2020-06-11 20:19:44 +02:00
if(MSYS2_FOLDER)
set(CMAKE_FIND_ROOT_PATH "${MSYS2_FOLDER}/mingw32")
endif()
2014-08-06 19:13:06 +02:00
# Ensure cmake doesn't find things in the wrong places
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Find programs on host
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Find libs in target
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target