Skip to content

Commit 78131d5

Browse files
committed
splitting compiler/platform-specific flags into corresponding files
1 parent 028a828 commit 78131d5

File tree

7 files changed

+55
-6
lines changed

7 files changed

+55
-6
lines changed

CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ foreach(FOLDER_NAME IN ITEMS layer0 layer1 layer2 layer3 layer4 layer5 ov)
1313
endforeach()
1414

1515
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
16-
include(Dependencies)
1716
include(Helpers)
18-
19-
target_link_options(${TARGET_NAME} PRIVATE
20-
"$<$<PLATFORM_ID:Darwin>:LINKER:-undefined,dynamic_lookup>"
21-
)
17+
include(Dependencies)
18+
# Darwin, Windows, Linux
19+
include(platform/${CMAKE_SYSTEM_NAME})
20+
# MSVC, GCC, Clang
21+
include(compiler/${CMAKE_CXX_COMPILER_FRONTEND_VARIANT})
2222

2323
target_compile_options(${TARGET_NAME} PRIVATE
2424
${ALL_COMP_ARGS}
@@ -46,7 +46,6 @@ target_include_directories(${TARGET_NAME} PUBLIC
4646

4747
target_link_directories(${TARGET_NAME} PUBLIC
4848
${ALL_LIB_DIR}
49-
$<$<CXX_COMPILER_ID:MSVC>:${Python_LIBRARY_DIRS}>
5049
)
5150
target_link_libraries(${TARGET_NAME}
5251
${ALL_LIB}

cmake/compiler/Clang.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include(compiler/GCC)

cmake/compiler/GNU.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
target_compile_options(${TARGET_NAME} PRIVATE
2+
-Werror=return-type
3+
-Wunused-variable
4+
-Wno-switch
5+
-Wno-narrowing
6+
-Wno-char-subscripts
7+
$<$<CONFIG:Debug>:-Og>
8+
$<$<NOT:$<CONFIG:Debug>>:-O3>
9+
)
10+
11+
target_compile_definitions(${TARGET_NAME} PUBLIC
12+
# bounds checking in STL containers
13+
$<$<CONFIG:Debug>:_GLIBCXX_ASSERTIONS>
14+
)

cmake/compiler/MSVC.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
target_compile_options(${TARGET_NAME} PRIVATE
2+
/MP
3+
/std:c++17
4+
$<$<CONFIG:Debug>:/Z7>
5+
)
6+
7+
target_link_libraries(${TARGET_NAME}
8+
# pyconfig.py forces linking against pythonXY.lib on MSVC
9+
$<$<CONFIG:Debug>:/DEBUG>
10+
)

cmake/platform/Darwin.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
target_link_options(${TARGET_NAME} PRIVATE
2+
LINKER:-undefined,dynamic_lookup
3+
)
4+
5+
target_compile_options(${TARGET_NAME} PRIVATE
6+
# optimization currently causes a clang segfault on OS X 10.9 when
7+
# compiling layer2/RepCylBond.cpp
8+
-fno-strict-aliasing
9+
)
10+
11+
target_compile_definitions(${TARGET_NAME} PUBLIC
12+
PYMOL_CURVE_VALIDATE
13+
)

cmake/platform/Linux.cmake

Whitespace-only changes.

cmake/platform/Windows.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
target_compile_definitions(${TARGET_NAME} PUBLIC
2+
WIN32
3+
)
4+
5+
target_link_directories(${TARGET_NAME} PUBLIC
6+
${Python_LIBRARY_DIRS}
7+
)
8+
9+
target_link_libraries(${TARGET_NAME}
10+
${Python_LIBRARIES}
11+
)
12+

0 commit comments

Comments
 (0)