Alan W. Irwin wrote:
On several different build systems I am maintaining,
target_link_libraries (or its swig equivalent) is used in the
following way to link in the
Python library.
target_link_libraries(<python target> ${PYTHON_LIBRARIES})
where PYTHON_LIBRARIES has been set by using the FindPythonLibs find
module. This approach works well on Unix with the "Unix Makefiles"
generator and also on Windows with the "MSYS Makefiles" generator,
But Arjen tells me this general approach fails when using the MSVC
compiler
and the "NMake Makefiles" generator _and_ if he sets
CMAKE_BUILD_TYPE:STRING=Debug.
[...]
So I am thinking of replacing the above target_link_libraries code
by the following:
if(NOT PYTHON_DEBUG_LIBRARIES)
# Required for platforms like Linux that don't set
PYTHON_DEBUG_LIBRARIES
set(PYTHON_DEBUG_LIBRARIES ${PYTHON_LIBRARIES})
endif(NOT PYTHON_DEBUG_LIBRARIES)
target_link_libraries(<python target>
general ${PYTHON_LIBRARIES}
optimized ${PYTHON_LIBRARIES}
debug ${PYTHON_DEBUG_LIBRARIES}
)
Is this the correct general cross-platform approach that should be
used for linking the python library (at least until FindPythonLibs
returns a more user-friendly PYTHON_LIBRARIES result) or is there a
better alternative? I ask this question because the
This will work as long as PYTHON_LIBRARIES contains only one element.
The debug/optimized keywords apply only to the immediately following
library, so if you have a list of libraries returned (currently unlikely
AFAIK) it may still cause bad results.
Have a look at the SelectLibraryConfigurations module, it does what you
did above and in 2.8.10.* also properly handles lists and the case where
both values are the same.
And from what I see (at least in the current code) FindPythonLibs
already does exaclty that. So which CMake version is Arjen using? And if
it is the most recent one, can you get him to debug why FindPythonLibs
doesn't work as expected?
Eike
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake