MantisBT - CMake
View Issue Details
0012438CMakeCMakepublic2011-09-01 04:202012-09-03 16:00
chrislu 
Brad King 
immediateblockalways
closedduplicate 
PCWindows7 x64 SP1
CMake 2.8.5 
 
0012438: add_command _needs_ CONFIGURATION parameter for multi-target environments
Why do i need to jump too such hoops to do a simple thing as to add different post build commands to release and debug builds... and then it does not even do what i want.

This just wants to add dll files for release and debug builds to the respective directories:


get_directory_property(link_dirs LINK_DIRECTORIES)
list(REMOVE_ITEM in_libraries debug optimized general)
list(REMOVE_ITEM link_dirs ${SCHISM_LIBRARY_DIR})
set(conf_list release debug)

foreach(conf ${conf_list})
    foreach(link_lib ${in_libraries})
        set(link_lib_dll ${link_lib}.dll)
        foreach(ldir ${link_dirs})
            set(dll_path ${ldir}/${conf}/${link_lib_dll})
            if (EXISTS ${dll_path})
                # make if fail for the wrong configuration
                string(REPLACE /${conf}/ "/$<CONFIGURATION>/" dll_path ${dll_path})
                add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                                   COMMAND if EXIST ${dll_path} ${CMAKE_COMMAND} -E echo "copying ${link_lib_dll} to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIGURATION>/"
                                   COMMAND if EXIST ${dll_path} ${CMAKE_COMMAND} -E copy_if_different ${dll_path} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIGURATION>/)
            endif (EXISTS ${dll_path})
        endforeach(ldir)
    endforeach(link_lib)
endforeach(conf)

No tags attached.
duplicate of 0009974closed Brad King CMake should support custom commands that can vary by configuration. 
Issue History
2011-09-01 04:20chrisluNew Issue
2012-03-09 14:42Brad KingRelationship addedrelated to 0009974
2012-03-09 14:44Brad KingRelationship replacedduplicate of 0009974
2012-03-09 14:49Brad KingNote Added: 0028885
2012-03-09 14:49Brad KingStatusnew => resolved
2012-03-09 14:49Brad KingResolutionopen => duplicate
2012-03-09 14:49Brad KingAssigned To => Brad King
2012-09-03 16:00David ColeNote Added: 0030833
2012-09-03 16:00David ColeStatusresolved => closed

Notes
(0028885)
Brad King   
2012-03-09 14:49   
Resolving as duplicate of 0009974 which requests a sample use case not covered by generator expressions before further progress can be made. Please post there if you have one.

I suggest going to the mailing list for further help without this feature.
(0030833)
David Cole   
2012-09-03 16:00   
Closing resolved issues that have not been updated in more than 4 months.