Hi,
I have a cmake project that generates an output file that I want to install.
For ‘single config’ builds (eg: makefile/ninja builds) the target output file is simply located in the ${CMAKE_CURRENT_BINARY_DIR}, but for ‘multi config’ builds (eg: msvc) the target is located in a Debug or Release subdirectory.
I also need to the rename the target in a specific way as it’s a python module so I am confused about how to go about locating the correct output file to install.
Here’s the bit of my CMakeLists.txt that declares the python module target, using the SWIG output:
add_library(libsgd_python SHARED sgd_wrap.c)
target_include_directories(libsgd_python PRIVATE ${Python_INCLUDE_DIRS})
target_link_libraries(libsgd_python PRIVATE libsgd ${Python_LIBRARIES})
set_target_properties(libsgd_python PROPERTIES OUTPUT_NAME _sgd)
set_target_properties(libsgd_python PROPERTIES PREFIX "")
if(SGD_OS_WINDOWS)
set_target_properties(libsgd_python PROPERTIES SUFFIX .pyd)
set(OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/_sgd.pyd)
else()
set(OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/_sgd.so)
endif()
install(FILES ${OUTPUT_FILE} ${CMAKE_CURRENT_BINARY_DIR}/sgd.py ${CMAKE_CURRENT_SOURCE_DIR}/helloworld.py DESTINATION python)
How do I compute the correct the right ${OUTPUT_FILE} in a way that works with both single and multi config builds?
Bye,
Mark