[CMake] adding extra target to CMakeLists.txt
Olaf Peter
ope-devel at gmx.de
Thu Feb 11 14:24:07 EST 2010
Tyler Roscoe schrieb:
> On Wed, Feb 10, 2010 at 09:08:50PM +0100, Olaf Peter wrote:
>> How can I add an extra lint/syntax check target for my executable, like:
>>
>> check-syntax:
>> c++ -o /dev/null ${CXX_FLAGS} ${CXX_DEFINES} -S ${MY_PROJECT_SOURCES}
>> .PHONY: check-syntax
>
> You'll want to look at add_custom_command() and maybe
> add_custom_target(). The FAQ has some examples you can look to as well.
I did try it and it doesn't work:
---8<--- CMakeList.txt
add_custom_target (syntax-check
COMMAND ${CXX} CHECK_SRC)
---8<---- build/src/Makefile
....
# Convenience name for target.
src/CMakeFiles/syntax-check.dir/rule:
cd /home/olaf/Projects/programming/cpp/build && $(MAKE) -f
CMakeFiles/Makefile2 src/CMakeFiles/syntax-check.dir/rule
.PHONY : src/CMakeFiles/syntax-check.dir/rule
# Convenience name for target.
syntax-check: src/CMakeFiles/syntax-check.dir/rule
.PHONY : syntax-check
# fast build rule for target.
syntax-check/fast:
cd /home/olaf/Projects/programming/cpp/build && $(MAKE) -f
src/CMakeFiles/syntax-check.dir/build.make
src/CMakeFiles/syntax-check.dir/build
.PHONY : syntax-check/fast
It shall be equivilanet to a 'lint' target.
Thanks,
Olaf
More information about the CMake
mailing list