Skip to content

Commit

Permalink
Migrate build system files to Conan 2
Browse files Browse the repository at this point in the history
  • Loading branch information
vsbogd committed Jul 29, 2024
1 parent d40a62b commit 96b380e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ExternalProject_Add(
"-DCMAKE_INSTALL_PREFIX=${HYPERONC_INSTALL_PREFIX}"
"-DCMAKE_BUILD_TYPE=${BUILD_CONFIGURATION}"
"-DCARGO_ARGS=${CARGO_ARGS}"
"-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake"
)

ExternalProject_Get_Property(hyperonc BINARY_DIR)
Expand All @@ -38,6 +39,7 @@ ExternalProject_Add(
"-DHYPERONC_INSTALL_PREFIX=${HYPERONC_INSTALL_PREFIX}"
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}/python"
"-DCMAKE_BUILD_TYPE=${BUILD_CONFIGURATION}"
"-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake"
INSTALL_COMMAND cmake -E echo "Skipping install step."
)

Expand Down
8 changes: 0 additions & 8 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ enable_testing()
option(BUILD_SHARED_LIBS "Build shared library" ON)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)

execute_process(
# --build is required to build dependencies from source under cibuildwheel
# environment
COMMAND cmake -E env CC= CXX= conan install --build -pr:b default -pr:h default -- ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

# HYPERONC_TARGET_DIR is used as a target dir for cargo. Cargo automatically adds
# `debug/release` suffix to the value of --target-dir argument so we need to
# calculate actual path to compiled library using $<CONFIG:...> cmake generator
Expand Down
5 changes: 3 additions & 2 deletions c/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
libcheck/0.15.2

[generators]
cmake
CMakeDeps
CMakeToolchain

[options]
libcheck:with_subunit=False
libcheck/*:with_subunit=False
12 changes: 7 additions & 5 deletions c/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
find_package(check REQUIRED)

set(TEST_SOURCES
test.c
int_gnd.c
Expand All @@ -6,21 +8,21 @@ set(TEST_SOURCES
)

add_executable(check_atom check_atom.c ${TEST_SOURCES})
target_link_libraries(check_atom hyperonc-shared CONAN_PKG::libcheck)
target_link_libraries(check_atom hyperonc-shared Check::check)
add_test(NAME check_atom COMMAND check_atom)

add_executable(check_space check_space.c ${TEST_SOURCES})
target_link_libraries(check_space hyperonc-shared CONAN_PKG::libcheck)
target_link_libraries(check_space hyperonc-shared Check::check)
add_test(NAME check_space COMMAND check_space)

add_executable(check_sexpr_parser check_sexpr_parser.c ${TEST_SOURCES})
target_link_libraries(check_sexpr_parser hyperonc-shared CONAN_PKG::libcheck)
target_link_libraries(check_sexpr_parser hyperonc-shared Check::check)
add_test(NAME check_sexpr_parser COMMAND check_sexpr_parser)

add_executable(check_types check_types.c ${TEST_SOURCES})
target_link_libraries(check_types hyperonc-shared CONAN_PKG::libcheck)
target_link_libraries(check_types hyperonc-shared Check::check)
add_test(NAME check_types COMMAND check_types)

add_executable(check_runner check_runner.c ${TEST_SOURCES})
target_link_libraries(check_runner hyperonc-shared CONAN_PKG::libcheck)
target_link_libraries(check_runner hyperonc-shared Check::check)
add_test(NAME check_runner COMMAND check_runner)
9 changes: 1 addition & 8 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development.Module)
message(STATUS "Python native modules installation path (Python3_SITEARCH): ${Python3_SITEARCH}")
message(STATUS "Python modules installation path (Python3_SITELIB): ${Python3_SITELIB}")

execute_process(
# --build is required to build dependencies from source under cibuildwheel
# environment
COMMAND conan install --build -- ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
include(${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake)

if(GIT)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
Expand All @@ -47,7 +40,7 @@ if(APPLE)
endif()

pybind11_add_module(hyperonpy MODULE ./hyperonpy.cpp)
target_link_libraries(hyperonpy PRIVATE "${hyperonc_STATIC_LIBRARY}")
target_link_libraries(hyperonpy PRIVATE "${hyperonc_STATIC_LIBRARY}" nonstd::optional-lite)
if(GIT)
target_link_libraries(hyperonpy PUBLIC ${PLATFORM_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
endif()
Expand Down
4 changes: 2 additions & 2 deletions python/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pybind11/2.10.1
optional-lite/3.5.0

[generators]
cmake_paths
cmake_find_package
CMakeDeps
CMakeToolchain

0 comments on commit 96b380e

Please sign in to comment.