Skip to content

Commit ed10d32

Browse files
committed
moving champ build process to a separate CMakeLists.txt file
1 parent 2cbd369 commit ed10d32

File tree

8 files changed

+139
-175
lines changed

8 files changed

+139
-175
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
glm `
9191
libpng `
9292
libxml2 `
93-
libnetcdf `
93+
libnetcdf
9494
9595
- name: Get additional sources
9696
run: |
@@ -100,7 +100,6 @@ jobs:
100100
Copy-Item -Recurse -Path mmtf-cpp/include\* -Destination "$env:CONDA_PREFIX\Library\include"
101101
git clone --depth 1 --single-branch --branch cpp_master https://github.com/msgpack/msgpack-c.git
102102
Copy-Item -Recurse -Path msgpack-c/include\* -Destination "$env:CONDA_PREFIX\Library\include"
103-
dir $env:CONDA_PREFIX\Library\include
104103
105104
- name: Build PyMOL
106105
run: |

CMakeLists.txt

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,96 @@
1-
cmake_minimum_required(VERSION 3.13)
1+
cmake_minimum_required(VERSION 3.15)
22

33
project(${TARGET_NAME})
44

55
set(CMAKE_VERBOSE_MAKEFILE on)
6+
set(Python_FIND_VIRTUALENV FIRST)
7+
set(Python_FIND_STRATEGY LOCATION)
68

7-
add_library(${TARGET_NAME} SHARED ${ALL_SRC})
9+
find_package(Python REQUIRED COMPONENTS Interpreter Development NumPy)
10+
11+
target_link_options(${TARGET_NAME} PRIVATE
12+
"$<$<PLATFORM_ID:Darwin>:LINKER:-undefined,dynamic_lookup>"
13+
)
814

9-
target_compile_options(${TARGET_NAME} PRIVATE ${ALL_COMP_ARGS})
15+
target_compile_options(${TARGET_NAME} PRIVATE
16+
${ALL_COMP_ARGS}
1017

11-
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ${SHARED_SUFFIX})
18+
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
19+
-Werror=return-type
20+
-Wunused-variable
21+
-Wno-switch
22+
-Wno-narrowing
23+
-Wno-char-subscripts
24+
$<$<CONFIG:Debug>:-Og>
25+
$<$<NOT:$<CONFIG:Debug>>:-O3>
26+
>
27+
$<$<CXX_COMPILER_ID:MSVC>:/MP>
28+
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Z7>
1229

13-
target_compile_features(${TARGET_NAME} PRIVATE cxx_std_17)
30+
# optimization currently causes a clang segfault on OS X 10.9 when
31+
# compiling layer2/RepCylBond.cpp
32+
$<$<PLATFORM_ID:Darwin>:-fno-strict-aliasing>
33+
)
1434

15-
set_target_properties(${TARGET_NAME} PROPERTIES PREFIX "")
35+
execute_process(
36+
COMMAND ${Python_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"
37+
OUTPUT_VARIABLE PYTHON_MODULE_SUFFIX
38+
OUTPUT_STRIP_TRAILING_WHITESPACE
39+
)
1640

17-
target_include_directories(${TARGET_NAME} PUBLIC ${ALL_INC_DIR})
41+
function(set_output_path lib path)
42+
set_target_properties(${lib} PROPERTIES
43+
PREFIX ""
44+
SUFFIX "${PYTHON_MODULE_SUFFIX}"
45+
OUTPUT_NAME "${lib}"
46+
LIBRARY_OUTPUT_DIRECTORY "${path}"
47+
RUNTIME_OUTPUT_DIRECTORY "${path}"
48+
)
1849

19-
target_link_directories(${TARGET_NAME} PUBLIC ${ALL_LIB_DIR})
50+
foreach(CONFIG IN ITEMS RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
51+
set_target_properties(${lib} PROPERTIES
52+
LIBRARY_OUTPUT_DIRECTORY_${CONFIG} "${path}"
53+
RUNTIME_OUTPUT_DIRECTORY_${CONFIG} "${path}"
54+
)
55+
endforeach()
56+
endfunction()
2057

58+
set_output_path(${TARGET_NAME} "${Python_SITEARCH}/pymol")
2159

22-
if(APPLE)
23-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
24-
endif()
60+
target_compile_features(${TARGET_NAME} PRIVATE cxx_std_17)
2561

62+
add_library(${TARGET_NAME} SHARED ${ALL_SRC})
63+
64+
target_include_directories(${TARGET_NAME} PUBLIC
65+
${CMAKE_CURRENT_SOURCE_DIR}/include
66+
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pocketfft
67+
${ALL_INC_DIR}
68+
${Python_INCLUDE_DIRS}
69+
${Python_NumPy_INCLUDE_DIRS}
70+
)
71+
72+
target_link_directories(${TARGET_NAME} PUBLIC
73+
${ALL_LIB_DIR}
74+
$<$<CXX_COMPILER_ID:MSVC>:${Python_LIBRARY_DIRS}>
75+
)
2676
target_link_libraries(${TARGET_NAME}
2777
${ALL_LIB}
2878
${ALL_EXT_LINK}
79+
$<$<CXX_COMPILER_ID:MSVC>:${Python_LIBRARIES}>
80+
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/DEBUG>
81+
)
82+
83+
target_compile_definitions(${TARGET_NAME} PUBLIC
84+
${ALL_DEF}
85+
_PYMOL_LIBPNG
86+
_PYMOL_FREETYPE
87+
_PYMOL_NUMPY
88+
$<$<CXX_COMPILER_ID:MSVC>:WIN32>
89+
$<$<PLATFORM_ID:Darwin>:PYMOL_CURVE_VALIDATE>
90+
91+
# bounds checking in STL containers
92+
# if DEBUG and not Windows
93+
$<$<AND:$<CONFIG:Debug>,$<NOT:$<CXX_COMPILER_ID:MSVC>>>:_GLIBCXX_ASSERTIONS>
2994
)
3095

31-
target_compile_definitions(${TARGET_NAME} PUBLIC ${ALL_DEF})
96+
add_subdirectory(contrib/champ)

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ See also: http://pymolwiki.org/index.php/Linux_Install
88
REQUIREMENTS
99

1010
- C++17 compiler (e.g. gcc 8+)
11-
- CMake (3.13+)
11+
- CMake (3.15+)
1212
- Python 3.9+
1313
- pip (with build submodule <pip install build>; conda's package name is python-build)
1414
- Pmw (Python Megawidgets) (optional, for legacy GUI/plugins)

contrib/champ/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
set(CHEMPY_PROJECT_NAME _champ)
2+
3+
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
4+
5+
add_library(${CHEMPY_PROJECT_NAME} MODULE ${SOURCES})
6+
7+
target_link_options(${CHEMPY_PROJECT_NAME} PRIVATE
8+
"$<$<PLATFORM_ID:Darwin>:LINKER:-undefined,dynamic_lookup>"
9+
)
10+
11+
target_include_directories(${CHEMPY_PROJECT_NAME} PUBLIC
12+
${Python_INCLUDE_DIRS}
13+
${CMAKE_CURRENT_SOURCE_DIR}
14+
)
15+
target_link_directories(${CHEMPY_PROJECT_NAME} PUBLIC
16+
$<$<CXX_COMPILER_ID:MSVC>:${Python_LIBRARY_DIRS}>
17+
)
18+
19+
target_link_libraries(${CHEMPY_PROJECT_NAME} PUBLIC
20+
$<$<CXX_COMPILER_ID:MSVC>:${Python_LIBRARIES}>
21+
)
22+
23+
set_output_path(${CHEMPY_PROJECT_NAME} "${Python_SITEARCH}/chempy/champ")
24+
25+
target_compile_features(${CHEMPY_PROJECT_NAME} PRIVATE cxx_std_17)

create_shadertext.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ def create_shadertext(
3939

4040
# get all *.gs *.vs *.fs *.shared from the two input directories
4141
shader_files = set(
42-
chain(
43-
(path for path in shader_dir.glob("**/*") if path.suffix in extension_regexp),
44-
(path for path in shader_dir2.glob("**/*") if path.suffix in extension_regexp)
45-
)
42+
path
43+
for path in chain(shader_dir.glob("**/*"), shader_dir2.glob("**/*"))
44+
if path.suffix in extension_regexp
4645
)
4746

4847
with (

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "pymol"
33
readme = "README.md"
44
requires-python = ">=3.9"
55
dynamic=["version"]
6-
license = {file = "LICENSE"}
6+
license-files = ["LICENSE"]
77
description = """
88
PyMOL is a Python-enhanced molecular graphics tool.
99
It excels at 3D visualization of proteins, small molecules, density,
@@ -21,9 +21,9 @@ dependencies = [
2121
build-backend = "backend"
2222
backend-path = ["_custom_build"]
2323
requires = [
24-
"cmake>=3.13.3",
24+
"cmake>=3.15.3",
2525
"numpy>=2.0",
26-
"setuptools>=69.2.0",
26+
"setuptools>=77.0.0",
2727
]
2828

2929
[project.optional-dependencies]

0 commit comments

Comments
 (0)