Skip to content

Commit 2ce35e6

Browse files
committed
splitting compiler/platform-specific flags into corresponding files
1 parent d17c7e5 commit 2ce35e6

File tree

7 files changed

+55
-32
lines changed

7 files changed

+55
-32
lines changed

CMakeLists.txt

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,15 @@ foreach(FOLDER_NAME IN ITEMS layer0 layer1 layer2 layer3 layer4 layer5 ov)
1515
endforeach()
1616

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

2525
target_compile_options(${TARGET_NAME} PRIVATE
2626
${ALL_COMP_ARGS}
27-
28-
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
29-
-Werror=return-type
30-
-Wunused-variable
31-
-Wno-switch
32-
-Wno-narrowing
33-
-Wno-char-subscripts
34-
$<$<CONFIG:Debug>:-Og>
35-
$<$<NOT:$<CONFIG:Debug>>:-O3>
36-
>
37-
$<$<CXX_COMPILER_ID:MSVC>:/MP>
38-
$<$<CXX_COMPILER_ID:MSVC>:/std:c++17>
39-
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Z7>
40-
41-
# optimization currently causes a clang segfault on OS X 10.9 when
42-
# compiling layer2/RepCylBond.cpp
43-
$<$<PLATFORM_ID:Darwin>:-fno-strict-aliasing>
4427
)
4528

4629
execute_process(
@@ -63,27 +46,17 @@ target_include_directories(${TARGET_NAME} PUBLIC
6346

6447
target_link_directories(${TARGET_NAME} PUBLIC
6548
${ALL_LIB_DIR}
66-
$<$<CXX_COMPILER_ID:MSVC>:${Python_LIBRARY_DIRS}>
6749
)
6850
target_link_libraries(${TARGET_NAME}
6951
${ALL_LIB}
7052
${ALL_EXT_LINK}
71-
# pyconfig.py forces linking against pythonXY.lib on MSVC
72-
$<$<CXX_COMPILER_ID:MSVC>:${Python_LIBRARIES}>
73-
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/DEBUG>
7453
)
7554

7655
target_compile_definitions(${TARGET_NAME} PUBLIC
7756
${ALL_DEF}
7857
_PYMOL_LIBPNG
7958
_PYMOL_FREETYPE
8059
_PYMOL_NUMPY
81-
$<$<CXX_COMPILER_ID:MSVC>:WIN32>
82-
$<$<PLATFORM_ID:Darwin>:PYMOL_CURVE_VALIDATE>
83-
84-
# bounds checking in STL containers
85-
# if DEBUG and not Windows compiler
86-
$<$<AND:$<CONFIG:Debug>,$<NOT:$<CXX_COMPILER_ID:MSVC>>>:_GLIBCXX_ASSERTIONS>
8760
)
8861

8962
add_subdirectory(contrib/champ)

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/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+

cmake/platform/linux.cmake

Whitespace-only changes.

0 commit comments

Comments
 (0)