From 4d0da20e31331819d27aba1f5ef77d08ec61aedb Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Wed, 1 Jan 2020 19:59:47 +0100 Subject: [PATCH] Fixes for Windows CI build. --- .drone.yml | 5 +++-- CMakeLists.txt | 24 ++++++++++++++---------- conanfile.py | 8 ++++++-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.drone.yml b/.drone.yml index 3adc237..e9ffc98 100644 --- a/.drone.yml +++ b/.drone.yml @@ -54,8 +54,9 @@ steps: - update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix - update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix - update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - - cmake -DCMAKE_BUILD_TYPE=Release . -B build-release-windows -D CMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc -D CMAKE_CXX_COMPILER=/usr/bin/x86_64-w64-mingw32-g++ -DWINDOWS=ON - - conan install . --install=folder=build-release-windows --build missing -s os_build=Linux -s arch_build=x86_64 -s os=Windows -s arch=x86_64 -s compiler=gcc -s compiler.version=7.3 -s compiler.libcxx=libstdc++11 -s build_type=Release + - cmake -DCMAKE_BUILD_TYPE=Release . -B build-release-windows -DWINDOWS=ON - cmake --build build-release-windows --target all -- -j 4 + - cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /home/build/build-release-windows/bin/ + - cp /home/build/build-release-windows/lib/libpkmnLib.so /home/build/build-release-windows/bin/ - export WINEARCH=win64 - wine build-release-windows/bin/pkmnLibTests.exe -s \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 0840a6d..5eca4f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,12 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) if (WINDOWS) + SET(CMAKE_SYSTEM_NAME Windows) ADD_DEFINITIONS(-D WINDOWS=1) +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") endif(WINDOWS) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") message(STATUS "Using: \t C ${CMAKE_C_COMPILER} @@ -20,7 +22,6 @@ message(STATUS "Using: \t CXX ABI ${CMAKE_CXX_COMPILER_ABI} \t C++ Version ${CMAKE_CXX_STANDARD}") - if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.") string(REPLACE "." ";" VERSION_LIST "${CMAKE_C_COMPILER_VERSION}") @@ -30,32 +31,35 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) SET(VERSION ${VERSION}.${MINOR}) endif() if (NOT WINDOWS) - execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing -s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION}) + execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing + -s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION}) else() - execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing -s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION}) + execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing + -s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows) endif() endif () include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() +message(STATUS "Using Conan Libs:") +foreach (_conanLib ${CONAN_LIBS}) + message(STATUS "\t ${_conanLib}") +endforeach() # Create Core library with files in src/Core file(GLOB_RECURSE CORE_SRC_FILES "src/*.cpp" "src/*.hpp") add_library(pkmnLib SHARED ${CORE_SRC_FILES}) -foreach (_variableName ${CONAN_LIBS}) - message(STATUS "Lib: ${_variableName}") -endforeach() - SET(_LINKS ${CONAN_LIBS}) SET(_TESTLINKS pkmnLib ${CONAN_LIBS}) if (WINDOWS) message(STATUS "Using Windows build.") + set(CMAKE_CXX_FLAGS "-L ${CMAKE_BINARY_DIR}/bin") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition") # Statically link libraries we need in Windows. - SET(_LINKS -static -static-libgcc -static-libstdc++ ${_LINKS}) - SET(_TESTLINKS -static -static-libgcc -static-libstdc++ ${_TESTLINKS}) + SET(_LINKS ${_LINKS} -static-libgcc -static-libstdc++) + SET(_TESTLINKS ${_TESTLINKS} -static-libgcc -static-libstdc++) endif (WINDOWS) diff --git a/conanfile.py b/conanfile.py index 4901169..8bdcdb4 100644 --- a/conanfile.py +++ b/conanfile.py @@ -6,13 +6,13 @@ class PkmnLibConan(ConanFile): license = "TODO" url = "https://git.p-epsilon.com/Deukhoofd/CreatureLib" description = "The core implementation for turn based battling using creatures." - settings = "compiler" + settings = "os", "compiler" options = {"shared": [True, False]} default_options = {"shared": True} generators = "cmake" exports_sources = "*" compiler = "clang" - requires = "CreatureLib/db2eb0c3fa5d67b14c84b118cd2f69bbd209ddb9@creaturelib/master" + requires = "CreatureLib/6e498429f9afaf2184efd7441e79f76e3cdf376d@creaturelib/master" def build(self): cmake = CMake(self) @@ -30,3 +30,7 @@ class PkmnLibConan(ConanFile): self.copy("*.dylib*", dst="lib", keep_path=False) self.copy("*.so", dst="lib", keep_path=False) self.copy("*.a", dst="lib", keep_path=False) + + def imports(self): + if self.settings.os == "Windows": + self.copy("*.dll", "bin", "bin")