From b5d8b89c38734c960899e3fd86cc08a29216f127 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Mon, 12 Apr 2021 18:50:50 +0200 Subject: [PATCH] Friendship with conan is over, ExternalProject is my best friend now. Signed-off-by: Deukhoofd --- CMakeLists.txt | 4 ++-- CMakeLists.txt.in | 46 +++++++++++++++++++++++++++++++++++++++ CmakeConanSetup.cmake | 24 --------------------- conanfile.py | 50 ------------------------------------------- 4 files changed, 48 insertions(+), 76 deletions(-) create mode 100644 CMakeLists.txt.in delete mode 100644 CmakeConanSetup.cmake delete mode 100644 conanfile.py diff --git a/CMakeLists.txt b/CMakeLists.txt index bfb0a68..13e04a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.16) include(CheckIPOSupported) +include(CMakeLists.txt.in) +include_arbutils() project(CreatureLib) @@ -24,8 +26,6 @@ if (CMAKE_BUILD_TYPE MATCHES Release AND NOT WINDOWS) add_compile_options(-g -gline-tables-only) endif () -include(CmakeConanSetup.cmake) -SetupConan() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in new file mode 100644 index 0000000..d2e4181 --- /dev/null +++ b/CMakeLists.txt.in @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(arbutils-download NONE) + +include(ExternalProject) +ExternalProject_Add(arbutils + GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Arbutils + GIT_TAG master + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/Arbutils" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) + + +function(include_arbutils) + # Download and unpack googletest at configure time + configure_file(CMakeLists.txt.in Arbutils/download/CMakeLists.txt) + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/download) + if (result) + message(FATAL_ERROR "CMake step for arbutils failed: ${result}") + endif () + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/download) + if (result) + message(FATAL_ERROR "Build step for arbutils failed: ${result}") + endif () + + # Add googletest directly to our build. This defines + # the gtest and gtest_main targets. + add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/Arbutils/src/arbutils + ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/bin + EXCLUDE_FROM_ALL) + + execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/include) + execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/src/arbutils/src + ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/include/Arbutils) + + include_directories(${CMAKE_CURRENT_BINARY_DIR}/Arbutils/include) + + +endfunction() \ No newline at end of file diff --git a/CmakeConanSetup.cmake b/CmakeConanSetup.cmake deleted file mode 100644 index d3f9113..0000000 --- a/CmakeConanSetup.cmake +++ /dev/null @@ -1,24 +0,0 @@ -function(SetupConan) - # If conan isn't set up yet, we need to install the dependencies. - if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.") - - # If we're linking C statically, we also want to do so for our dependencies. - 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 -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=$ENV{CONAN_ENV_COMPILER_VERSION} - -s os=Windows -o - *:shared=True -o *:staticC=${CONAN_STATIC_C}) - endif () - endif () - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - conan_basic_setup() -endfunction() \ No newline at end of file diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index 38b353e..0000000 --- a/conanfile.py +++ /dev/null @@ -1,50 +0,0 @@ -from conans import ConanFile, CMake - - -class CreatureLibConan(ConanFile): - name = "CreatureLib" - license = "TODO" - 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], "staticC": [True, False], "level_size": [8, 16, 32, 64]} - default_options = {"shared": True, "staticC": False, "level_size": 8} - generators = "cmake" - exports_sources = "*" - compiler = "clang" - - def build(self): - cmake = CMake(self) - self.output.info("Target OS: %s." % self.settings.os) - if self.settings.os == "Windows": - self.output.warn("Noticed Windows target, setting Cmake WINDOWS=On.") - cmake.definitions["WINDOWS"] = "On" - if self.options.shared: - self.output.info("Building shared library.") - cmake.definitions["SHARED"] = "On" - if self.options.staticC: - self.output.info("Linking C libraries statically") - cmake.definitions["STATICC"] = "ON" - self.output.info("Using level size of: %s" % self.options.level_size) - cmake.definitions["LEVEL_SIZE"] = self.options.level_size - - cmake.configure() - cmake.build() - - def package(self): - self.copy("*.hpp", dst="include/CreatureLib", src="src") - self.copy("*.hxx", dst="include/CreatureLib", src="src") - self.copy("*.dll", dst="bin", 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") - self.copy("*.a", "", "bin") - - def package_info(self): - self.cpp_info.libs = ["CreatureLib"] - - def requirements(self): - self.requires("Arbutils/latest@epsilon/master")