From 8088aa159fac0a1f576288943b03e2e6da9cdcf4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 20 Aug 2018 11:47:39 +0200 Subject: [PATCH] CMake 2.8.12 and lower allowed the SOURCE signature in add_custom_command In CMake 3.0 the policy CMP0050 was introduced where it could be set to OLD to keep this behaviour while for NEW an error was raised. Since CMake 3.5.2 a warning comes up when using the OLD behaviour and that it will be removed in a future version. In FreeCAD we switched to the new behaviour now and removed the SOURCE signature from add_custom_command which affects the macros fc_copy_sources, fc_target_copy_resource and fc_target_copy_resource_flat and their usage. It's not possible any more to add files to a target by using the macros. Now a file must be added to the target before using the macros. This commit fixes it for Arch, Draft, OpenSCAD, Material, Plot and Ship --- cMake/FreeCadMacros.cmake | 8 +++--- src/Mod/Arch/CMakeLists.txt | 19 ++++++------ src/Mod/Draft/CMakeLists.txt | 18 ++++++++---- src/Mod/Material/CMakeLists.txt | 6 ++-- src/Mod/OpenSCAD/CMakeLists.txt | 51 ++++++++++++++++++--------------- src/Mod/Plot/CMakeLists.txt | 20 +++++++------ src/Mod/Ship/CMakeLists.txt | 19 +++++++----- 7 files changed, 82 insertions(+), 59 deletions(-) diff --git a/cMake/FreeCadMacros.cmake b/cMake/FreeCadMacros.cmake index 0b21a6189e..87713b904a 100644 --- a/cMake/FreeCadMacros.cmake +++ b/cMake/FreeCadMacros.cmake @@ -15,9 +15,9 @@ MACRO (fc_copy_sources target_name outpath) add_file_dependencies("${infile}" "${outfile}") ADD_CUSTOM_COMMAND( COMMAND "${CMAKE_COMMAND}" -E copy "${infile}" "${outfile}" - TARGET ${target_name} - OUTPUTS "${outfile}" + OUTPUT "${outfile}" COMMENT "Copying ${infile} to ${outfile}${fc_details}" + MAIN_DEPENDENCY "${infile}" ) endforeach(it) ADD_CUSTOM_COMMAND( @@ -49,9 +49,9 @@ MACRO (fc_target_copy_resource target_name inpath outpath) add_file_dependencies("${infile}" "${outfile}") ADD_CUSTOM_COMMAND( COMMAND "${CMAKE_COMMAND}" -E copy "${infile}" "${outfile}" - TARGET ${target_name} - OUTPUTS "${outfile}" + OUTPUT "${outfile}" COMMENT "Copying ${infile} to ${outfile}${fc_details}" + MAIN_DEPENDENCY "${infile}" ) endforeach(it) ADD_CUSTOM_COMMAND( diff --git a/src/Mod/Arch/CMakeLists.txt b/src/Mod/Arch/CMakeLists.txt index f075aea764..7222090d08 100644 --- a/src/Mod/Arch/CMakeLists.txt +++ b/src/Mod/Arch/CMakeLists.txt @@ -56,12 +56,17 @@ SET(Arch_presets SOURCE_GROUP("" FILES ${Arch_SRCS}) +SET(ArchGuiIcon_SVG + Resources/icons/ArchWorkbench.svg +) + ADD_CUSTOM_TARGET(Arch ALL - SOURCES ${Arch_SRCS} ${Arch_QRC_SRCS} + SOURCES ${Arch_SRCS} ${Arch_QRC_SRCS} ${Dice3DS_SRCS} ${Arch_presets} ${ArchGuiIcon_SVG} ) fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/Mod/Arch" ${Arch_SRCS}) fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/Mod/Arch" ${Dice3DS_SRCS}) +fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Arch" ${ArchGuiIcon_SVG}) fc_target_copy_resource(Arch ${CMAKE_SOURCE_DIR}/src/Mod/Arch @@ -88,7 +93,6 @@ INSTALL( ${Dice3DS_SRCS} DESTINATION Mod/Arch/Dice3DS ) - INSTALL( DIRECTORY Presets @@ -96,11 +100,10 @@ INSTALL( ${CMAKE_INSTALL_DATADIR}/Mod/Arch FILES_MATCHING PATTERN "*.csv*" ) - -SET(ArchGuiIcon_SVG - Resources/icons/ArchWorkbench.svg +INSTALL( + FILES + ${ArchGuiIcon_SVG} + DESTINATION + "${CMAKE_INSTALL_DATADIR}/Mod/Arch/Resources/icons" ) -fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Arch" ${ArchGuiIcon_SVG}) - -INSTALL(FILES ${ArchGuiIcon_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/Arch/Resources/icons") diff --git a/src/Mod/Draft/CMakeLists.txt b/src/Mod/Draft/CMakeLists.txt index 8ca57a9ff5..8888880d6f 100644 --- a/src/Mod/Draft/CMakeLists.txt +++ b/src/Mod/Draft/CMakeLists.txt @@ -24,12 +24,18 @@ SET(Draft_SRCS ) SOURCE_GROUP("" FILES ${Draft_SRCS}) +SET(DraftGuiIcon_SVG + Resources/icons/DraftWorkbench.svg +) + ADD_CUSTOM_TARGET(Draft ALL - SOURCES ${Draft_SRCS} ${Draft_QRC_SRCS} + SOURCES ${Draft_SRCS} ${Draft_QRC_SRCS} ${DraftGuiIcon_SVG} ) fc_copy_sources(Draft "${CMAKE_BINARY_DIR}/Mod/Draft" ${Draft_SRCS}) +fc_copy_sources(Draft "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Draft" ${DraftGuiIcon_SVG}) + IF (BUILD_GUI) fc_target_copy_resource(Draft ${CMAKE_CURRENT_BINARY_DIR} @@ -45,10 +51,10 @@ INSTALL( Mod/Draft ) -SET(DraftGuiIcon_SVG - Resources/icons/DraftWorkbench.svg +INSTALL( + FILES + ${DraftGuiIcon_SVG} + DESTINATION + "${CMAKE_INSTALL_DATADIR}/Mod/Draft/Resources/icons" ) -fc_copy_sources(Draft "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Draft" ${DraftGuiIcon_SVG}) - -INSTALL(FILES ${DraftGuiIcon_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/Draft/Resources/icons") diff --git a/src/Mod/Material/CMakeLists.txt b/src/Mod/Material/CMakeLists.txt index 2cdbfd6798..4691095406 100644 --- a/src/Mod/Material/CMakeLists.txt +++ b/src/Mod/Material/CMakeLists.txt @@ -40,7 +40,7 @@ ADD_CUSTOM_TARGET(Material ALL ) fc_target_copy_resource(Material - ${CMAKE_SOURCE_DIR}/src/Mod/Material + ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/Mod/Material ${Material_SRCS}) @@ -61,11 +61,11 @@ ADD_CUSTOM_TARGET(FluidMaterialLib ALL # When a target copies files to different output directories then apparently it always builds the project # which is very annoying. So, the trick is to split this into two targets to avoid this behaviour. fc_target_copy_resource(MaterialLib - ${CMAKE_SOURCE_DIR}/src/Mod/Material + ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Material ${MaterialLib_Files}) fc_target_copy_resource(FluidMaterialLib - ${CMAKE_SOURCE_DIR}/src/Mod/Material + ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Material ${FluidMaterial_Files}) diff --git a/src/Mod/OpenSCAD/CMakeLists.txt b/src/Mod/OpenSCAD/CMakeLists.txt index d2bf4b9c59..0d404a37b6 100644 --- a/src/Mod/OpenSCAD/CMakeLists.txt +++ b/src/Mod/OpenSCAD/CMakeLists.txt @@ -3,37 +3,43 @@ IF (BUILD_GUI) ENDIF (BUILD_GUI) SET(OpenSCAD_SRCS - Init.py - InitGui.py - OpenSCAD2Dgeom.py - OpenSCADFeatures.py - OpenSCADUtils.py - OpenSCADCommands.py - exportCSG.py - importCSG.py - tokrules.py - colorcodeshapes.py - expandplacements.py - replaceobj.py + Init.py + InitGui.py + OpenSCAD2Dgeom.py + OpenSCADFeatures.py + OpenSCADUtils.py + OpenSCADCommands.py + exportCSG.py + importCSG.py + tokrules.py + colorcodeshapes.py + expandplacements.py + replaceobj.py ) SOURCE_GROUP("" FILES ${OpenSCAD_SRCS}) SET(ply_SRCS - ply/lex.py - ply/README - ply/yacc.py - ply/__init__.py + ply/lex.py + ply/README + ply/yacc.py + ply/__init__.py ) SOURCE_GROUP("ply" FILES ${ply_SRCS}) set(all_files ${OpenSCAD_SRCS} ${ply_SRCS}) +SET(OpenSCADGuiIcon_SVG + Resources/icons/OpenSCADWorkbench.svg +) + ADD_CUSTOM_TARGET(OpenSCAD ALL - SOURCES ${allfiles} ${OpenSCAD_QRC_SRCS} + SOURCES ${all_files} ${OpenSCAD_QRC_SRCS} ${OpenSCADGuiIcon_SVG} ) fc_copy_sources(OpenSCAD "${CMAKE_BINARY_DIR}/Mod/OpenSCAD" ${all_files}) +fc_copy_sources(OpenSCAD "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/OpenSCAD" ${OpenSCADGuiIcon_SVG}) + IF (BUILD_GUI) fc_target_copy_resource(OpenSCAD ${CMAKE_CURRENT_BINARY_DIR} @@ -54,11 +60,10 @@ INSTALL( DESTINATION Mod/OpenSCAD ) - -SET(OpenSCADGuiIcon_SVG - Resources/icons/OpenSCADWorkbench.svg +INSTALL( + FILES + ${OpenSCADGuiIcon_SVG} + DESTINATION + "${CMAKE_INSTALL_DATADIR}/Mod/OpenSCAD/Resources/icons" ) -fc_copy_sources(OpenSCAD "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/OpenSCAD" ${OpenSCADGuiIcon_SVG}) - -INSTALL(FILES ${OpenSCADGuiIcon_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/OpenSCAD/Resources/icons") diff --git a/src/Mod/Plot/CMakeLists.txt b/src/Mod/Plot/CMakeLists.txt index fd94bcd1d5..3dfb371793 100644 --- a/src/Mod/Plot/CMakeLists.txt +++ b/src/Mod/Plot/CMakeLists.txt @@ -52,12 +52,18 @@ SOURCE_GROUP("plotutils" FILES ${PlotUtils_SRCS}) SET(all_files ${PlotMain_SRCS} ${PlotAxes_SRCS} ${PlotLabels_SRCS} ${PlotPositions_SRCS} ${PlotSave_SRCS} ${PlotSeries_SRCS} ${PlotUtils_SRCS}) +SET(PlotGuiIcon_SVG + resources/icons/PlotWorkbench.svg +) + ADD_CUSTOM_TARGET(Plot ALL - SOURCES ${all_files} ${Plot_QRC_SRCS} + SOURCES ${all_files} ${Plot_QRC_SRCS} ${PlotGuiIcon_SVG} ) fc_copy_sources(Plot "${CMAKE_BINARY_DIR}/Mod/Plot" ${all_files}) +fc_copy_sources(Plot "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Plot" ${PlotGuiIcon_SVG}) + IF (BUILD_GUI) fc_target_copy_resource(Plot ${CMAKE_CURRENT_BINARY_DIR} @@ -108,11 +114,9 @@ INSTALL( DESTINATION Mod/Plot ) - -SET(PlotGuiIcon_SVG - resources/icons/PlotWorkbench.svg +INSTALL( + FILES + ${PlotGuiIcon_SVG} + DESTINATION + "${CMAKE_INSTALL_DATADIR}/Mod/Plot/resources/icons" ) - -fc_copy_sources(Plot "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Plot" ${PlotGuiIcon_SVG}) - -INSTALL(FILES ${PlotGuiIcon_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/Plot/resources/icons") diff --git a/src/Mod/Ship/CMakeLists.txt b/src/Mod/Ship/CMakeLists.txt index 5a7e881d4f..910bd4588b 100644 --- a/src/Mod/Ship/CMakeLists.txt +++ b/src/Mod/Ship/CMakeLists.txt @@ -112,12 +112,18 @@ SOURCE_GROUP("shiputils" FILES ${ShipUtils_SRCS}) SET(all_files ${ShipMain_SRCS} ${ShipExamples_SRCS} ${ShipLoadExample_SRCS} ${ShipCreateShip_SRCS} ${ShipOutlineDraw_SRCS} ${ShipAreasCurve_SRCS} ${ShipHydrostatics_SRCS} ${ShipCreateWeight_SRCS} ${ShipCreateTank_SRCS} ${ShipCapacityCurve_SRCS} ${ShipCreateLoadCondition_SRCS} ${ShipGZ_SRCS} ${ShipUtils_SRCS}) +SET(ShipGuiIcon_SVG + resources/icons/ShipWorkbench.svg +) + ADD_CUSTOM_TARGET(Ship ALL - SOURCES ${all_files} ${Ship_QRC_SRCS} + SOURCES ${all_files} ${Ship_QRC_SRCS} ${ShipGuiIcon_SVG} ) fc_copy_sources(Ship "${CMAKE_BINARY_DIR}/Mod/Ship" ${all_files}) +fc_copy_sources(Ship "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Ship" ${ShipGuiIcon_SVG}) + IF(BUILD_GUI) fc_target_copy_resource(Ship ${CMAKE_CURRENT_BINARY_DIR} @@ -204,11 +210,10 @@ INSTALL( DESTINATION Mod/Ship ) - -SET(ShipGuiIcon_SVG - resources/icons/ShipWorkbench.svg +INSTALL( + FILES + ${ShipGuiIcon_SVG} + DESTINATION + "${CMAKE_INSTALL_DATADIR}/Mod/Ship/resources/icons" ) -fc_copy_sources(Ship "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Ship" ${ShipGuiIcon_SVG}) - -INSTALL(FILES ${ShipGuiIcon_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/Ship/resources/icons")