[CMake] CMake generated makefiles try to build a target that does not exist (make[2]: *** No rule to make target ...)

Bill Tonkin wmt at clinton.com
Fri Oct 6 14:35:55 EDT 2006


Hello All,

The short story is that the CMake generated makefiles try to build a target
that seems to exist, but with a slightly different name.

    make[2]: *** No rule to make target
`../../libraries/my_a/CMakeFiles/my_a.di
r/build'.


-------------
The long story is ...

I'm investigating CMake as an alternative to our current build system which
uses a commercial IDE and hand rolled makefiles. (Solaris, forte, gnu) My
plan
is to leave the existing source code directory structure as-is (except for
the
addition of CMakeList.txt files) so that the current tool set will continue
to
work without modification.  Obviously I need to set this up as an
out-of-source build so that the CMake generated stuff will not end up in the
source tree.  Before attempting to set up a real, and therefore fairly
complex,
build I thought I'd try a simple example in my home directory, albeit one
with
the same sort of directory structure as is used for the production source
code.

The directory layout is:


     /users/wmt/cmake_system/
                            |
                            systems/my_one/
                            |             |
                            |             CMakeLists.txt [1]
                            |             main.C
                            |
                            libraries/my_a/
                            |             |
                            |             CMakeLists.txt [2]
                            |             my_a.C
                            |             my_a.h
                            |
                            |
                            cmake_build/
                                       |
                                       systems/my_one/
                                       |             |
                                       |             CMakeCache.txt
                                       |
                                       libraries/my_a/



----
The content of CMakeLists.txt [1] is:

project (my_one)
set (my_a_dir ../../libraries/my_a)
add_subdirectory (${my_one_SOURCE_DIR}/${my_a_dir}
                  ${my_one_BINARY_DIR}/${my_a_dir})
include_directories (${my_one_SOURCE_DIR}/${my_a_dir})
link_directories (${my_one_BINARY_DIR}/${my_a_dir})
add_executable (my_one_exe main.C)
target_link_libraries (my_one_exe my_a)

----
The content of CMakeLists.txt [2] is:

add_library (my_a my_a.C)

----

So now I
    cd /users/wmt/cmake_system/cmake_build/systems/my_one
    cmake ../../../systems/my_one
    make


And I get (edited for clarity):

    make -f ../../libraries/my_a/CMakeFiles/my_a.dir/build.make
                     ../../libraries/my_a/CMakeFiles/my_a.dir/build
    make[2]: Entering directory
`/users/wmt/cmake_system/cmake_build/systems/my_
one'
    make[2]: *** No rule to make target
`../../libraries/my_a/CMakeFiles/my_a.di
r/build'.



To be clear, the CMake generated makefiles
   /users/wmt/cmake_system/cmake_build/systems/my_one/Makefile

and
  /users/wmt/cmake_system/cmake_build/systems/my_one/CMakeFiles/Makefile2


both contain the line:

    $(MAKE) -f ../../libraries/my_a/CMakeFiles/my_a.dir/build.make
../../librari
es/my_a/CMakeFiles/my_a.dir/build

Unfortunately, the makefile they refer to contains:

# Rule to build all files generated by this target.
/users/wmt/cmake_system/cmake_build/libraries/my_a/CMakeFiles/my_a.dir/build
: /u
sers/wmt/cmake_system/cmake_build/libraries/my_a/libmy_a.a

and the target name
   ../../libraries/my_a/CMakeFiles/my_a.dir/build

is close to but does NOT match

/users/wmt/cmake_system/cmake_build/libraries/my_a/CMakeFiles/my_a.dir/build



Is this a bug?  Any ideas how on what I should do?






More information about the CMake mailing list