diff --git a/.drone.yml b/.drone.yml index 00acf68..abf21e5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,7 +17,7 @@ steps: CXX: /usr/bin/clang++ commands: - conan remote add epsilon-public https://packages.p-epsilon.com/ - - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-debug + - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-debug -DSTATICC=ON - cmake --build build-debug --target all -- -j 4 - build-debug/bin/CreatureLibTests -s --durations yes --use-colour yes - name: test-release-linux @@ -30,7 +30,7 @@ steps: CXX: /usr/bin/clang++ commands: - conan remote add epsilon-public https://packages.p-epsilon.com/ - - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-release + - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-release -DSTATICC=ON - cmake --build build-release --target all -- -j 4 - build-release/bin/CreatureLibTests -s --durations yes --use-colour yes - valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no --error-exitcode=1 build-release/bin/CreatureLibTests diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a9b0cd..f167b89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,12 +16,17 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) if (NOT MINOR MATCHES 0) SET(VERSION ${VERSION}.${MINOR}) endif () + set(CONAN_STATIC_C False) + if (STATICC) + set(CONAN_STATIC_C True) + endif (STATICC) + if (NOT WINDOWS) execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated - -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 -o *:staticC=${CONAN_STATIC_C}) else () 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 -o *:shared=True) + -s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows -o *:shared=True -o *:staticC=${CONAN_STATIC_C}) endif () endif () include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) @@ -50,6 +55,7 @@ if (WINDOWS) endif (WINDOWS) if (STATICC) + message(STATUS "Linking C statically.") SET(_LIBRARYLINKS ${_LIBRARYLINKS} -static-libgcc -static-libstdc++) SET(_BATTLINGLINKS ${_BATTLINGLINKS} -static-libgcc -static-libstdc++) if (NOT DEFINED CONAN_EXPORTED) diff --git a/conanfile.py b/conanfile.py index bf7b70a..fa1ce69 100644 --- a/conanfile.py +++ b/conanfile.py @@ -7,8 +7,8 @@ class CreatureLibConan(ConanFile): url = "https://git.p-epsilon.com/Deukhoofd/CreatureLib" description = "The core implementation for turn based battling using creatures." settings = "os", "compiler" - options = {"shared": [True, False]} - default_options = {"shared": True} + options = {"shared": [True, False], "staticC": [True, False]} + default_options = {"shared": True, "staticC": False} generators = "cmake" exports_sources = "*" compiler = "clang" @@ -19,13 +19,12 @@ class CreatureLibConan(ConanFile): if self.settings.os == "Windows": self.output.warn("Noticed Windows target, setting Cmake WINDOWS=On.") cmake.definitions["WINDOWS"] = "On" + if self.options.staticC: + self.output.info("Linking C libraries statically") + cmake.definitions["STATICC"] = "ON" cmake.configure() cmake.build() - # Explicit way: - # self.run('cmake "%s/src" %s' % (self.source_folder, cmake.command_line)) - # self.run("cmake --build . %s" % cmake.build_config) - def package(self): self.copy("*.hpp", dst="include/CreatureLib", src="src") self.copy("*.dll", dst="bin", keep_path=False)