[Qt-creator] Add OTHER_FILE function to CMake project

Peter Kümmel syntheticpp at gmx.net
Thu Aug 23 13:33:03 CEST 2012


On 22.08.2012 10:58, Stefano Cordibella wrote:
> I try to use add_library:
> ADD_LIBRARY(Other
>       README Changelog
> )
> and the files appears in the Project tab, great!
> But when I run CMake I get this error:
>
> CMake Error: CMake can not determine linker language for target:Other
>
> CMake Error: Cannot determine link language for target "Other".
>
> I try to add EXCLUDE_FROM_ALL flag in the add_library, but nothing change...
>
> Searching on google i found this other trick:
> SET(OTHER
>       README
>       Changelog)
> ADD_CUSTOM_TARGET(UtilityHeaders OTHER ${OTHER})
> This one don't generate error from CMake but the files are not displayed
> in project tab...
>
> Any other ideas?
>

Add the files to a real target and mark the files as headers:


macro(add_info_files)
     foreach(_it ${ARGN})
         if(NOT IS_DIRECTORY ${_it})
             get_filename_component(name ${_it} NAME)
             if(NOT ${_it} MATCHES "^/\\\\..*$;~$")
                 set_source_files_properties(${_it} PROPERTIES HEADER_FILE_ONLY TRUE)
             endif()
         endif()
     endforeach()
endmacro()


set(info README Changelog)
add_info_files(${info})
add_library(foo ${real_source_files} ${info})


Peter




More information about the Qt-creator mailing list