Pecevski Dejan wrote:
> Filipe Sousa wrote:
> 
> Hi Filipe,
> Thanks for the reply.
> I have setup a simple example based on your solution, but it doesn't 
> seem to work. Files of the example are attached to the e-mail.
> Basically in the example I am building a library libtest from these files:
> a.cpp - source for the library
> a.h - header file (it includes b.h)
> copy.h - generated header file by simple copying a.h. This file is 
> included in a.cpp.
> b.h - file included in a.h
> 
> The CMakeLists.txt is as follows:
> -------------------------------
> ADD_CUSTOM_COMMAND( OUTPUT copy.h
>                     COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/a.h 
> ${CMAKE_CURRENT_SOURCE_DIR}/copy.h
>                     DEPENDS a.h
>                     )
> 
> INCLUDE_DIRECTORIES( $CMAKE_CURRENT_SOURCE_DIR )
> 
> ADD_LIBRARY( test a.cpp copy.h )
> ------------------------------
> 
> The library builds ok, but the copy.h file is not really dependent of 
> b.h, and it should be, because a.h includes it. So the question is, how 
> to make
> this kind of dependency work?

ADD_CUSTOM_COMMAND(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/copy.h
  COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/a.h
${CMAKE_CURRENT_BINARY_DIR}/copy.h
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/a.h
  )
INCLUDE_DIRECTORIES(
  ${CMAKE_CURRENT_BINARY_DIR} # for copy.h
  ${CMAKE_CURRENT_SOURCE_DIR} # becasuse copy.h needs b.h
  )
ADD_LIBRARY(test
  a.cpp
  ${CMAKE_CURRENT_BINARY_DIR}/copy.h
  a.h
  )

[EMAIL PROTECTED] ~/tmp/example/cmake_example/build $ l
total 32
-rw-r--r-- 1 fsousa fsousa 9831 2006-10-11 11:56 CMakeCache.txt
drwxr-xr-x 4 fsousa fsousa  432 2006-10-11 11:56 CMakeFiles
-rw-r--r-- 1 fsousa fsousa 1445 2006-10-11 11:56 cmake_install.cmake
-rw-r--r-- 1 fsousa fsousa 4051 2006-10-11 11:56 Makefile
-rw-r--r-- 1 fsousa fsousa 4005 2006-10-11 11:56 Project.vpj
-rw-r--r-- 1 fsousa fsousa  241 2006-10-11 11:56 Project.vpw
-rw-r--r-- 1 fsousa fsousa   36 2006-10-11 11:56 Project.vpwhistu

[EMAIL PROTECTED] ~/tmp/example/cmake_example/build $ make
[ 50%] Generating copy.h
Scanning dependencies of target test
[100%] Building CXX object CMakeFiles/test.dir/a.o
Linking CXX static library libtest.a
[100%] Built target test

[EMAIL PROTECTED] ~/tmp/example/cmake_example/build $ make
[100%] Built target test

[EMAIL PROTECTED] ~/tmp/example/cmake_example/build $ touch ../a.h

[EMAIL PROTECTED] ~/tmp/example/cmake_example/build $ make
[ 50%] Generating copy.h
Scanning dependencies of target test
[100%] Building CXX object CMakeFiles/test.dir/a.o
Linking CXX static library libtest.a
[100%] Built target test

[EMAIL PROTECTED] ~/tmp/example/cmake_example/build $ touch ../b.h

[EMAIL PROTECTED] ~/tmp/example/cmake_example/build $ make
Scanning dependencies of target test
[ 50%] Building CXX object CMakeFiles/test.dir/a.o
Linking CXX static library libtest.a
[100%] Built target test

[EMAIL PROTECTED] ~/tmp/example/cmake_example/build $ cmake --version
cmake version 2.5-20061006


> And the other problem is that I don't know what is the list of generated 
> wrapper c++ files, until they are generated, and I need the list
> to include it in a ADD_LIBRARY statement for the wrapper library.
> 
> Is there a way to accomplish this?
> 
> Thanks,
> Dejan


-- 
Filipe Sousa

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to