Skip to content

Commit 4c98305

Browse files
jcfrjamesobutler
authored andcommitted
cmake: Set PYTHONQT_SUPPORT_NAME_PROPERTY as target compile property
This changes the `PYTHONQT_SUPPORT_NAME_PROPERTY` definition from a global `add_definition` to a target-specific compile definition and adds the CMake option `PythonQt_SUPPORT_NAME_PROPERTY` set to ON by default.
1 parent a2a1598 commit 4c98305

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ find_package(PythonLibs REQUIRED)
5757
include_directories("${PYTHON_INCLUDE_DIR}")
5858
add_definitions(
5959
-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK
60-
-DPYTHONQT_SUPPORT_NAME_PROPERTY
6160
)
6261

6362
#-----------------------------------------------------------------------------
6463
# Build options
6564

65+
option(PythonQt_SUPPORT_NAME_PROPERTY "Enable PythonQt name-property support" ON)
66+
6667
if(NOT DEFINED PythonQt_INSTALL_RUNTIME_DIR)
6768
set(PythonQt_INSTALL_RUNTIME_DIR bin)
6869
endif()
@@ -317,6 +318,11 @@ add_library(PythonQt SHARED
317318
)
318319
set_target_properties(PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS)
319320

321+
target_compile_definitions(PythonQt
322+
PRIVATE
323+
$<$<BOOL:${PythonQt_SUPPORT_NAME_PROPERTY}>:PYTHONQT_SUPPORT_NAME_PROPERTY>
324+
)
325+
320326
target_compile_options(PythonQt PRIVATE
321327
$<$<CXX_COMPILER_ID:MSVC>:/bigobj>
322328
)
@@ -374,6 +380,11 @@ if(BUILD_TESTING)
374380
add_executable(PythonQtCppTests ${test_sources})
375381
target_link_libraries(PythonQtCppTests PythonQt)
376382

383+
target_compile_definitions(PythonQtCppTests
384+
PRIVATE
385+
$<$<BOOL:${PythonQt_SUPPORT_NAME_PROPERTY}>:PYTHONQT_SUPPORT_NAME_PROPERTY>
386+
)
387+
377388
add_test(
378389
NAME tests_PythonQtTestMain
379390
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:PythonQtCppTests> tests/PythonQtTestMain

0 commit comments

Comments
 (0)