townforge/external/CMakeLists.txt
Crypto City bcd0d9dea1 make this build on windows
Thanks to syksy and iDunk for testing/debugging on windows
2020-06-14 23:43:30 +00:00

145 lines
6.2 KiB
CMake

# Copyright (c) 2014-2019, 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.
#
# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
# This is broken up into two parts: first we check for miniupnp, compile it if we can't
# find it, and thereafter we check for libunbound, and compile it if we can't find it.
# We always compile if we are building statically to reduce static dependency issues...
# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with
# others.
find_package(Miniupnpc REQUIRED)
message(STATUS "Using in-tree miniupnpc")
add_subdirectory(miniupnp/miniupnpc)
set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
if(MSVC)
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
elseif(NOT MSVC)
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -D_NETBSD_SOURCE")
endif()
set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
find_package(Unbound)
if(NOT UNBOUND_INCLUDE_DIR OR STATIC)
# NOTE: If STATIC is true, CMAKE_FIND_LIBRARY_SUFFIXES has been reordered.
# unbound has config tests which used OpenSSL libraries, so -ldl may need to
# be set in this case.
# The unbound CMakeLists.txt can set it, since it's also needed for the
# static OpenSSL libraries set up there after with target_link_libraries.
add_subdirectory(unbound)
set(UNBOUND_STATIC true PARENT_SCOPE)
set(UNBOUND_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/unbound/libunbound" PARENT_SCOPE)
set(UNBOUND_LIBRARY "unbound" PARENT_SCOPE)
set(UNBOUND_LIBRARY_DIRS "${LIBEVENT2_LIBDIR}" PARENT_SCOPE)
else()
message(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}")
if(UNBOUND_LIBRARIES)
message(STATUS "Found libunbound shared library")
set(UNBOUND_STATIC false PARENT_SCOPE)
set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE)
set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE)
set(UNBOUND_LIBRARY_DIRS "" PARENT_SCOPE)
else()
die("Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent")
endif()
endif()
add_subdirectory(db_drivers)
add_subdirectory(easylogging++)
add_subdirectory(randomx EXCLUDE_FROM_ALL)
if (WIN32)
set(URHO3D_LIB_TYPE STATIC)
set(URHO3D_STATIC_DEFINE "-DURHO3D_STATIC_DEFINE=1")
else()
set(URHO3D_LIB_TYPE SHARED)
endif()
include(ExternalProject)
ExternalProject_Add(urho3d_ext
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/urho3d"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/urho3d"
DOWNLOAD_COMMAND cmake -E echo ""
UPDATE_COMMAND cmake -E echo ""
INSTALL_COMMAND cmake -E echo ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DURHO3D_PLAYER=0 -DURHO3D_SAMPLES=0 -DURHO3D_TOOLS=0 -DURHO3D_LIB_TYPE=${URHO3D_LIB_TYPE}
-DURHO3D_LUA=0 -DURHO3D_ANGELSCRIPT=0 -DURHO3D_BINDINGS=0 -DURHO3D_NETWORK=0 -DURHO3D_PHYSICS=0 -DURHO3D_WEBP=0 -DURHO3D_IK=0
-DURHO3D_DATABASE=0 -DURHO3D_DATABASE_ODBC=0 -DURHO3D_DATABASE_SQLITE=0 -DURHO3D_NAVIGATION=0
-DURHO3D_USE_LIB_DEB=1 -DURHO3D_DOCS=0 -DURHO3D_PCH=0 ${URHO3D_STATIC_DEFINE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_COMMAND make
INSTALL_COMMAND cmake -E echo ""
)
add_library(urho3d UNKNOWN IMPORTED)
set_target_properties(urho3d PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/urho3d/lib/${CMAKE_STATIC_LIBRARY_PREFIX}Urho3D${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
set(URHO3D_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/urho3d/lib/${CMAKE_STATIC_LIBRARY_PREFIX}Urho3D${CMAKE_STATIC_LIBRARY_SUFFIX}")
add_dependencies(urho3d urho3d_ext)
if (WIN32)
set(BOOTSTRAP_EXT "bat")
else()
set(BOOTSTRAP_EXT "sh")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(TOOLSET clang)
else()
set(TOOLSET gcc)
endif()
ExternalProject_Add(boost_ext
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/boost-libs"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/boost-libs"
DOWNLOAD_COMMAND cmake -E echo ""
UPDATE_COMMAND cmake -E echo ""
INSTALL_COMMAND cmake -E echo ""
CONFIGURE_COMMAND cmake -E echo ""
BUILD_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/boost-libs/make_townforge.sh ${TOOLSET} ${ARCH_WIDTH} ${CMAKE_CURRENT_SOURCE_DIR}/boost-libs ${CMAKE_CURRENT_BINARY_DIR}/boost-libs ${BOOTSTRAP_EXT} "${CXX_SECURITY_FLAGS} -fPIC -DPIC"
INSTALL_COMMAND cmake -E echo ""
)
add_library(boost UNKNOWN IMPORTED)
set_target_properties(boost PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/boost/lib/${CMAKE_STATIC_LIBRARY_PREFIX}boost${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
add_dependencies(boost boost_ext)
add_subdirectory(procsky)
add_subdirectory(tb)
add_subdirectory(freetype)