diff --git a/CMakeLists.txt b/CMakeLists.txt index b379559..c085cd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.17) project(LADEL-dev) -enable_testing() +include(CTest) # Add coverage target option(LADEL_WITH_COVERAGE @@ -20,4 +20,6 @@ endif() # TODO: add warning flags add_subdirectory(LADEL) -add_subdirectory(test) \ No newline at end of file +if (BUILD_TESTING) + add_subdirectory(test) +endif() \ No newline at end of file diff --git a/LADEL/cmake/Config.cmake.in b/LADEL/cmake/Config.cmake.in index 6d4a8ca..ee215e1 100644 --- a/LADEL/cmake/Config.cmake.in +++ b/LADEL/cmake/Config.cmake.in @@ -1,3 +1,3 @@ @PACKAGE_INIT@ -include ("${CMAKE_CURRENT_LIST_DIR}/ladelTargets.cmake") +include ("${CMAKE_CURRENT_LIST_DIR}/LADELTargets.cmake") diff --git a/LADEL/cmake/Install.cmake b/LADEL/cmake/Install.cmake index bb60a48..2d15b52 100644 --- a/LADEL/cmake/Install.cmake +++ b/LADEL/cmake/Install.cmake @@ -1,6 +1,6 @@ include(GNUInstallDirs) -set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/ladel") +set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") # Add the ladel library to the "export-set", install the library files install(TARGETS ladel EXPORT ladelTargets @@ -29,7 +29,7 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" # Install the export set for use with the install-tree install(EXPORT ladelTargets - FILE ladelTargets.cmake + FILE ${PROJECT_NAME}Targets.cmake DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev NAMESPACE ${PROJECT_NAME}::) @@ -38,23 +38,23 @@ install(EXPORT ladelTargets include(CMakePackageConfigHelpers) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in" - "${PROJECT_BINARY_DIR}/ladelConfig.cmake" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}" NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO) write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/ladelConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" VERSION "${PROJECT_VERSION}" COMPATIBILITY SameMajorVersion) -# Install the ladelConfig.cmake and ladelConfigVersion.cmake +# Install the LADELConfig.cmake and LADELConfigVersion.cmake install(FILES - "${PROJECT_BINARY_DIR}/ladelConfig.cmake" - "${PROJECT_BINARY_DIR}/ladelConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) # Add all targets to the build tree export set export(EXPORT ladelTargets - FILE "${PROJECT_BINARY_DIR}/ladelTargets.cmake" + FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake" NAMESPACE ${PROJECT_NAME}::) diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..5b902a6 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,70 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.build import can_run + + +class LADELRecipe(ConanFile): + name = "ladel" + version = "0.0.1" + + # Optional metadata + license = "LGPLv3" + author = "Pieter P " + url = "https://github.com/kul-optec/LADEL" + description = "Quasidefinite LDL factorization package with (symmetric) row/column adds and deletes" + topics = ("LDL", "LDLT", "linear-algebra") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = ( + "CMakeLists.txt", + "LADEL/*", + "thirdparty/*", + "test/*", + "LICENSE", + "README.md", + ) + + generators = ("CMakeDeps",) + + def requirements(self): + self.test_requires("gtest/1.11.0") + + def config_options(self): + if self.settings.get_safe("os") == "Windows": + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + if can_run(self): + tc.variables["LADEL_FORCE_TEST_DISCOVERY"] = True + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + cmake.test() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "none") + self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "LADEL")) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 70dac62..8751f11 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -27,4 +27,7 @@ target_include_directories(ladel_run_all_tests target_link_libraries(ladel_run_all_tests PRIVATE ladel) target_link_libraries(ladel_run_all_tests PRIVATE GTest::gtest_main) -gtest_discover_tests(ladel_run_all_tests DISCOVERY_TIMEOUT 60) +option(LADEL_FORCE_TEST_DISCOVERY Off) +if (NOT CMAKE_CROSSCOMPILING OR LADEL_FORCE_TEST_DISCOVERY) + gtest_discover_tests(ladel_run_all_tests DISCOVERY_TIMEOUT 60) +endif()