Skip to content

Commit

Permalink
update cpp location
Browse files Browse the repository at this point in the history
  • Loading branch information
kaihsin committed Dec 3, 2024
1 parent b10b28e commit 39391a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
41 changes: 21 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,54 +26,55 @@ include(version.cmake)
set(CYTNX_CORE_VERSION
${CYTNX_CORE_VERSION_MAJOR}.${CYTNX_CORE_VERSION_MINOR}.${CYTNX_CORE_VERSION_PATCH}
)
set(PKG_NAME "cytnx_core") # only need to change this for different pkg

## Project:
project(CYTNX_CORE VERSION ${CYTNX_CORE_VERSION} LANGUAGES CXX C)
add_library(cytnx_core STATIC)
set_property(TARGET cytnx_core PROPERTY C_VISIBILITY_PRESET hidden)
set_property(TARGET cytnx_core PROPERTY VISIBILITY_INLINES_HIDDEN ON)
add_library(${PKG_NAME} STATIC)
set_property(TARGET ${PKG_NAME} PROPERTY C_VISIBILITY_PRESET hidden)
set_property(TARGET ${PKG_NAME} PROPERTY VISIBILITY_INLINES_HIDDEN ON)

message(STATUS " Current source dir: ${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(cytnx_core
target_include_directories(${PKG_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/src
PUBLIC
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${PKG_name}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/include>
)
# cpp source directory
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/src)
target_compile_definitions(cytnx_core PUBLIC _LIBCPP_DISABLE_AVAILABILITY)
target_compile_definitions(cytnx_core PUBLIC _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
target_compile_options(cytnx_core PUBLIC -Wformat=0 -w -fsized-deallocation)
target_compile_features(cytnx_core PUBLIC cxx_std_17)
target_compile_definitions(${PKG_NAME} PUBLIC _LIBCPP_DISABLE_AVAILABILITY)
target_compile_definitions(${PKG_NAME} PUBLIC _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
target_compile_options(${PKG_NAME} PUBLIC -Wformat=0 -w -fsized-deallocation)
target_compile_features(${PKG_NAME} PUBLIC cxx_std_17)


## install
include(GNUInstallDirs)

message(STATUS " install libdir: ${CMAKE_INSTALL_LIBDIR}")
message(STATUS " install includedir: ${CMAKE_INSTALL_INCLUDEDIR}")
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/cytnx_core)
INSTALL(TARGETS cytnx_core EXPORT cytnx_targets
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG_NAME})
INSTALL(TARGETS ${PKG_NAME} EXPORT ${PKG_NAME}_targets
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
DESTINATION ${PKG_NAME}/cpp/${CMAKE_INSTALL_LIBDIR}
COMPONENT libraries
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
DESTINATION ${PKG_NAME}/cpp/${CMAKE_INSTALL_LIBDIR}
COMPONENT libraries
PUBLIC_HEADER
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION ${PKG_NAME}/cpp/${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Development
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION ${PKG_NAME}/cpp/${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers
FILES_MATCHING PATTERN "*.h*")


export(EXPORT cytnx_targets FILE ${CMAKE_CURRENT_BINARY_DIR}/CytnxTargets.cmake NAMESPACE cytnx_core::)
export(PACKAGE cytnx_core)
export(EXPORT ${PKG_NAME}_targets FILE ${CMAKE_CURRENT_BINARY_DIR}/${PKG_NAME}_targets.cmake NAMESPACE ${PKG_NAME}::)
export(PACKAGE ${PKG_NAME})

# #####################################################################
# Pybind
Expand All @@ -82,12 +83,12 @@ set(PYBIND11_FINDPYTHON ON)
find_package(pybind11 CONFIG REQUIRED)

pybind11_add_module(_core MODULE src/cpp/pybind/main.cpp)
target_link_libraries(_core PUBLIC cytnx_core)
target_link_libraries(_core PUBLIC ${PKG_NAME})

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/cytnx_core
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/${PKG_NAME}
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install(TARGETS _core LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/cytnx_core)
install(TARGETS _core LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${PKG_NAME})
#install(TARGETS pycytnx DESTINATION ${SKBUILD_PROJECT_NAME})
message(STATUS " skbuild Installation Prefix: ${SKBUILD_PROJECT_NAME}")
message(STATUS " skbuild Installation Prefix: ${SKBUILD_HEADERS_DIR}")
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ authors = [
{ name = "kaihsin", email = "[email protected]" }
]
requires-python = ">=3.10"
dependencies = []
dependencies = [
"torch>=2.5.1",
]

[tool.scikit-build]
minimum-version = "build-system.requires"
Expand Down

0 comments on commit 39391a9

Please sign in to comment.