File: CMakeLists.txt

package info (click to toggle)
avogadrolibs 1.101.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 78,500 kB
  • sloc: cpp: 139,792; ansic: 2,212; python: 1,435; perl: 321; sh: 90; makefile: 46
file content (72 lines) | stat: -rw-r--r-- 1,999 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

if (NOT TARGET Avogadro::Core)
  find_package(AvogadroLibs REQUIRED)
endif()
find_package(Python COMPONENTS Interpreter Development)
set(PYBIND11_PYTHON_VERSION "3" CACHE STRING "")
set(PYBIND11_CPP_STANDARD "-std=c++17" CACHE STRING "")
find_package(pybind11 REQUIRED)

set(wrapper_SRCS
  main.cpp
  core.cpp
  io.cpp
  )

set(_python_module_install_dir "avogadro")
# SKBUILD is set for binary wheel
if (NOT SKBUILD)
  set(_python_module_install_dir "${Python_SITEARCH}/avogadro")
endif()

set(CMAKE_MODULE_LINKER_FLAGS "")
# Core
pybind11_add_module(avogadrocorepython core.cpp)
set_target_properties(avogadrocorepython
  PROPERTIES
    OUTPUT_NAME core)
target_link_libraries(avogadrocorepython
  PRIVATE
    Avogadro::Core
    pybind11::module
)

install(TARGETS avogadrocorepython LIBRARY COMPONENT python DESTINATION "${_python_module_install_dir}")

# IO
pybind11_add_module(avogadroiopython io.cpp)
set_target_properties(avogadroiopython
  PROPERTIES
    OUTPUT_NAME io)
target_link_libraries(avogadroiopython
  PRIVATE
    Avogadro::IO
    Avogadro::QuantumIO
    pybind11::module
)
install(TARGETS avogadroiopython LIBRARY COMPONENT python DESTINATION "${_python_module_install_dir}")

# Set the RPATH so the dependent libraries can be found in the wheel.
if(APPLE)
  set(_rpath_value "@loader_path")
elseif(UNIX)
  set(_rpath_value "$ORIGIN")
endif()

if (NOT WIN32)
  set_target_properties(avogadrocorepython avogadroiopython PROPERTIES
                        INSTALL_RPATH ${_rpath_value})
endif()

# Install the python files.
FILE(GLOB PY_SRCS "avogadro/*.py")
install(FILES ${PY_SRCS} COMPONENT python DESTINATION "${_python_module_install_dir}")

# Set the output directory so the python modules can be used from the build
# tree.
set_target_properties(avogadrocorepython avogadroiopython
  PROPERTIES
    ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/avogadro"
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/avogadro"
)