[CMake] adding extra target to CMakeLists.txt

Ryan Pavlik rpavlik at iastate.edu
Thu Feb 11 15:04:27 EST 2010


Load them from the target using the target properties:
get_directory_property(_include_dirs INCLUDE_DIRECTORIES)
set(_includeflags)
foreach(_dir ${_include_dirs})
     list(APPEND _args "${YOURTOOL_INCLUDEPATH_ARG}${_dir}")
endforeach()

get_target_property(_sources "${_targetname}" SOURCES)
set(_files)
foreach(_source ${_sources})
     get_source_file_property(_lang "${_source}" LANGUAGE)
     get_source_file_property(_loc "${_source}" LOCATION)
     if("${_lang}" MATCHES "CXX")
         list(APPEND _files "${_loc}")
     endif()
endforeach()

Repeat with COMPILE_DEFINITIONS (and the per-config ones, if you want to 
make it fancy) and COMPILE_FLAGS.


Also, you may want to note: trying to troubleshoot your CMake files by 
looking at the generated Makefiles is generally a futile endeavor - 
better to just try a make VERBOSE=1 to see what's actually being run.  
(There's a lot of clutter in the generated makefiles to support all the 
slick stuff CMake gives us for free.)

Ryan

On 02/11/2010 01:41 PM, Olaf Peter wrote:
> OK, now I have it:
>
> add_custom_target (syntax-check
>   COMMAND $(CXX) $(CXXFLAGS) -Wall -Wextra -pedantic -fsyntax-only
> $(CHECK_SRC) VERBATIM)
>
>
> But how can I get there the Defines and Includes from regular target
> compile?
>
> Thanks,
> Olaf
> _______________________________________________
> 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
>    

-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik



More information about the CMake mailing list