On Thu, 7 Nov 2013 19:56:29 +0000
"Williams, Norman K" <[email protected]> wrote:
> Why doesn't this work?
> add_custom_command(
> ...
Good point, that's the core of my question.
I did implement the "add_custom_command" as you suggested, including
"dependencies". Unfortunatly, the custom command is not executed.
What happens is:
----
$ rm -rf build-cmake/
$ mkdir build-cmake
$ cd build-cmake/
$ cmake -G "MSYS Makefiles" \
> -DCMAKE_TOOLCHAIN_FILE=../src/toolchain-m68k-elf.cmake \
> ../src
-- Configuring done
-- Generating done
-- Build files have been written to:
C:/devel/projekte/cmake_test_custom_command/build-cmake
$ make
Scanning dependencies of target cmake_test
[100%] Building C object CMakeFiles/cmake_test.dir/hello.c.obj
Linking C executable cmake_test
c:/devel/msys-gcc-m68k-elf/local/coldfire/bin/../lib/gcc/m68k-elf/4.7.3/../../../../m68k-elf/bin/ld.exe:
cannot open linker script file api.lds: No such file or directory
...
----
As you can see, the custom command is not executed.
File "CMakeLists.txt":
----
project (cmake_test_custom_command)
cmake_minimum_required (VERSION 2.8)
set(CMAKE_MAKE_PROGRAM c:/devel/msys-gcc-m68k-elf/bin/make)
add_executable(cmake_test hello.c)
include_directories(inc)
set(CMAKE_EXE_LINKER_FLAGS "-T api.lds")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api.lds
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/api.lds.S
COMMAND ${CMAKE_C_COMPILER}
-E ${CMAKE_CURRENT_SOURCE_DIR}/api.lds.S -P
-o ${CMAKE_CURRENT_BINARY_DIR}/api.lds
-I ${CMAKE_CURRENT_SOURCE_DIR}/inc
VERBATIM )
add_dependencies(cmake_test ${CMAKE_CURRENT_BINARY_DIR}/api.lds)
----
> The actual target that needs the linker script needs to depend on api.lds ...
That's clear (I'm familiar with build systems in general).
Did I add the dependency (on cmake_test) correctly in my CMakeLists.txt?
If yes, why is the dependency "not working"?
Best Regards
Michael
File "toolchain-m68k-elf.cmake":
----
include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME Generic)
CMAKE_FORCE_C_COMPILER(m68k-elf-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(m68k-elf-g++ GNU)
set(CMAKE_SYSTEM_PROCESSOR 5372)
----
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake