Skip to content

Commit 595799e

Browse files
committed
moving champ build process to a separate CMakeLists.txt file
1 parent c6dcc6d commit 595799e

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ project(${TARGET_NAME})
44

55
set(CMAKE_VERBOSE_MAKEFILE on)
66

7+
find_package(Python REQUIRED COMPONENTS Interpreter Development)
8+
79
add_library(${TARGET_NAME} SHARED ${ALL_SRC})
810

911
target_compile_options(${TARGET_NAME} PRIVATE ${ALL_COMP_ARGS})
@@ -26,6 +28,7 @@ endif()
2628
target_link_libraries(${TARGET_NAME}
2729
${ALL_LIB}
2830
${ALL_EXT_LINK}
31+
${Python_LIBRARIES}
2932
)
3033

3134
target_compile_definitions(${TARGET_NAME} PUBLIC ${ALL_DEF})

contrib/champ/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
set(CHEMPY_PROJECT_NAME _champ)
4+
set(CMAKE_VERBOSE_MAKEFILE on)
5+
6+
project(${CHEMPY_PROJECT_NAME} LANGUAGES C)
7+
8+
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
9+
add_library(${CHEMPY_PROJECT_NAME} MODULE ${SOURCES})
10+
11+
target_include_directories(${CHEMPY_PROJECT_NAME} PUBLIC
12+
${Python_INCLUDE_DIRS}
13+
${CMAKE_CURRENT_SOURCE_DIR}
14+
)
15+
target_link_directories(${TARGET_NAME} PUBLIC
16+
${ALL_LIB_DIR}
17+
${Python_LIBRARY_DIRS}
18+
)
19+
target_link_libraries(${CHEMPY_PROJECT_NAME} PUBLIC
20+
${Python_LIBRARIES}
21+
)
22+
set_target_properties(${CHEMPY_PROJECT_NAME} PROPERTIES
23+
PREFIX ""
24+
SUFFIX "${PYTHON_MODULE_EXT}"
25+
OUTPUT_NAME "${CHEMPY_PROJECT_NAME}"
26+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/modules/chempy/champ"
27+
)
28+
target_compile_features(${CHEMPY_PROJECT_NAME} PRIVATE cxx_std_17)

setup.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def create_buildinfo(output_dir_path: str, pymoldir: str = "."):
129129
"""
130130
)
131131

132+
132133
# handle extra arguments
133134
def str2bool(v: str) -> bool:
134135
if v.lower() in ("true", "yes"):
@@ -166,7 +167,7 @@ class options:
166167
"--jobs",
167168
"-j",
168169
type=int,
169-
help="for parallel builds " "(defaults to number of processors)",
170+
help="for parallel builds (defaults to number of processors)",
170171
)
171172
parser.add_argument(
172173
"--libxml",
@@ -430,9 +431,7 @@ def install_pymol_path(self, base_path):
430431
self.copy(name, os.path.join(base_path, name))
431432

432433
if options.openvr:
433-
self.copy(
434-
"contrib/vr/README.md", os.path.join(base_path, "README-VR.txt")
435-
)
434+
self.copy("contrib/vr/README.md", os.path.join(base_path, "README-VR.txt"))
436435

437436
def make_launch_script(self):
438437
if sys.platform.startswith("win"):
@@ -674,7 +673,7 @@ def make_launch_script(self):
674673
break
675674
else:
676675
raise LookupError(
677-
"VTK-m headers not found." f' PREFIX_PATH={":".join(prefix_path)}'
676+
f"VTK-m headers not found. PREFIX_PATH={':'.join(prefix_path)}"
678677
)
679678
def_macros += [
680679
("_PYMOL_VTKM", None),
@@ -737,19 +736,13 @@ def get_sources(subdirs, suffixes=(".c", ".cpp")):
737736
[f for d in subdirs for s in suffixes for f in glob.glob(d + "/*" + s)]
738737
)
739738

740-
# Python includes
741739
inc_dirs.append(sysconfig.get_paths()["include"])
742740
inc_dirs.append(sysconfig.get_paths()["platinclude"])
743741

744742
champ_inc_dirs = ["contrib/champ"]
745743
champ_inc_dirs.append(sysconfig.get_paths()["include"])
746744
champ_inc_dirs.append(sysconfig.get_paths()["platinclude"])
747745

748-
if WIN:
749-
# pyconfig.py forces linking against pythonXY.lib on MSVC
750-
py_lib = Path(sysconfig.get_paths()["stdlib"]).parent / "libs"
751-
lib_dirs.append(str(py_lib))
752-
753746
ext_modules += [
754747
CMakeExtension(
755748
name="pymol._cmd",
@@ -761,7 +754,7 @@ def get_sources(subdirs, suffixes=(".c", ".cpp")):
761754
extra_link_args=ext_link_args,
762755
extra_compile_args=ext_comp_args,
763756
),
764-
CMakeExtension(
757+
CMakeExtension(
765758
name="chempy.champ._champ",
766759
sources=get_sources(["contrib/champ"]),
767760
include_dirs=champ_inc_dirs,

0 commit comments

Comments
 (0)