Rework of cmake file.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-05-02 15:55:31 +02:00
parent 27fb623a43
commit 8e5dd2fca5
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 27 additions and 29 deletions

View File

@ -50,7 +50,7 @@ steps:
- update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix - 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-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 - 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=x86_64-w64-mingw32-g++ -DWINDOWS=ON - cmake -DCMAKE_BUILD_TYPE=Release . -B build-release-windows -D CMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc -D CMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DWINDOWS=ON -DSTATICC=ON
- cmake --build build-release-windows --target all -- -j 4 - cmake --build build-release-windows --target all -- -j 4
- cp /drone/src/build-release-windows/lib/* /drone/src/build-release-windows/bin/ - cp /drone/src/build-release-windows/lib/* /drone/src/build-release-windows/bin/
- cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /drone/src/build-release-windows/bin/ - cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /drone/src/build-release-windows/bin/

View File

@ -21,7 +21,7 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
-s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -o *:shared=True) -s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -o *:shared=True)
else () else ()
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated
-s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows) -s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows -o *:shared=True)
endif () endif ()
endif () endif ()
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
@ -39,37 +39,33 @@ add_library(CreatureLibLibrary SHARED ${LIBRARY_SRC_FILES})
file(GLOB_RECURSE BATTLING_SRC_FILES "src/Battling/*.cpp" "src/Battling/*.hpp" "CInterface/Battling/*.cpp" "CInterface/Core.*") file(GLOB_RECURSE BATTLING_SRC_FILES "src/Battling/*.cpp" "src/Battling/*.hpp" "CInterface/Battling/*.cpp" "CInterface/Core.*")
add_library(CreatureLibBattling SHARED ${BATTLING_SRC_FILES}) add_library(CreatureLibBattling SHARED ${BATTLING_SRC_FILES})
SET(_LIBRARYLINKS Arbutils)
SET(_BATTLINGLINKS CreatureLibLibrary Arbutils)
SET(_TESTLINKS CreatureLibLibrary CreatureLibBattling Arbutils)
if (WINDOWS)
message(STATUS "Using Windows build.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L ${CMAKE_BINARY_DIR}/bin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition")
endif (WINDOWS)
if (STATICC)
SET(_LINKS ${_LINKS} -static-libgcc -static-libstdc++)
if (NOT DEFINED CONAN_EXPORTED)
SET(_TESTLINKS ${_TESTLINKS} -static-libgcc -static-libstdc++)
endif ()
endif ()
target_link_libraries(CreatureLibLibrary PUBLIC ${_LIBRARYLINKS})
target_link_libraries(CreatureLibBattling PUBLIC ${_BATTLINGLINKS})
if (NOT DEFINED CONAN_EXPORTED) if (NOT DEFINED CONAN_EXPORTED)
# Create Test executable # Create Test executable
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp) add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp)
endif () message(STATUS "${_TESTLINKS}")
target_link_libraries(CreatureLibTests PUBLIC ${_TESTLINKS})
# Link the library data to the Battling library
target_link_libraries(CreatureLibBattling CreatureLibLibrary)
target_link_libraries(CreatureLibLibrary Arbutils)
target_link_libraries(CreatureLibBattling Arbutils)
if (NOT DEFINED CONAN_EXPORTED)
target_link_libraries(CreatureLibTests CreatureLibLibrary)
target_link_libraries(CreatureLibTests CreatureLibBattling)
endif ()
if (WINDOWS)
MESSAGE(WARNING, "Using Windows Build.")
set(CMAKE_CXX_FLAGS "${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.
target_link_libraries(CreatureLibLibrary -static -static-libgcc -static-libstdc++)
target_link_libraries(CreatureLibBattling -static -static-libgcc -static-libstdc++)
if (NOT DEFINED CONAN_EXPORTED)
target_link_libraries(CreatureLibTests -static -static-libgcc -static-libstdc++)
endif ()
endif (WINDOWS)
if (NOT DEFINED CONAN_EXPORTED)
MESSAGE(WARNING, "Called from Conan. Not building test build.")
# Add a definition for the test library # Add a definition for the test library
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD) target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
endif () endif ()

View File

@ -30,10 +30,12 @@ class CreatureLibConan(ConanFile):
self.copy("*.hpp", dst="include/CreatureLib", src="src") self.copy("*.hpp", dst="include/CreatureLib", src="src")
self.copy("*.dll", dst="bin", keep_path=False) self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.so", dst="lib", keep_path=False) self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
def imports(self): def imports(self):
if self.settings.os == "Windows": if self.settings.os == "Windows":
self.copy("*.dll", "bin", "bin") self.copy("*.dll", "bin", "bin")
self.copy("*.a", "bin", "bin")
def package_info(self): def package_info(self):
self.cpp_info.libs = ["CreatureLibCore", "CreatureLibLibrary", "CreatureLibBattling"] self.cpp_info.libs = ["CreatureLibCore", "CreatureLibLibrary", "CreatureLibBattling"]