Hi,

I'll check ADD_DEPENDENCIES more closely if it fits the requirements, thanks.

However, I may already have a solution for add_subdirectory duplicates - you can simply force cmake to only include the subdirectory once. It's ugly but it seems to work (ENV hack is to force 100% global scope for the variable).

if(NOT ENV{already_liba})
        set(ENV{already_liba} 1)
        add_subdirectory(liba liba)
endif(NOT ENV{already_liba})

This could be an interesting macro, maybe ADD_SHARED_SUBDIRECTORY?

regards,
Egon


Bätge wrote:
Hi Egon,

it seems "add_subdirectory(${liba_dir} ${liba_dir})" is called twice (for exea 
and exeb).

Instead of usage "include(../liba/include.cmake)" you you should use:
ADD_DEPENDENCIES( exea liba ) ADD_DEPENDENCIES( exeb liba )

Hence, "link_libraries(liba)" is probably redundant.

st

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Egon Kocjan
Sent: Donnerstag, 3. April 2008 23:49
To: cmake@cmake.org
Subject: [CMake] acyclic subdirectory builds

Hello again,

I am slowly porting a complicated project to cmake. I have an acyclic graph of 
dependencies and "shared" build directories and I have trouble generating VS 
slns. A simple example (the real build is way more
complicated):

liba/include.cmake:
get_filename_component(liba_dir ${CMAKE_CURRENT_LIST_FILE} PATH) 
add_subdirectory(${liba_dir} ${liba_dir})
include_directories(${liba_dir})
link_libraries(liba)

liba/CMakeLists.txt:
add_library(liba a.cpp)

exea/CMakeLists.txt:
include(../liba/include.cmake)
add_executable(exea x.cpp)

exeb/CMakeLists.txt:
include(../liba/include.cmake)
add_executable(exeb y.cpp)

proj/CMakeLists.txt:
add_subdirectory(../exea ../exea)
add_subdirectory(../exeb ../exeb)

The idea here is that libraries use 100% modular include files. When I run 
cmake I get this in .sln:

Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", ".\ZERO_CHECK.vcproj", 
"{CDAEE59D-0373-4F41-9CF9-8DFA13581522}"
        ProjectSection(ProjectDependencies) = postProject
        EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "exea", "C:\temp\exea\exea.vcproj", 
"{83ED0A1A-2D2D-489B-8C48-0D8F77FD3E5B}"
        ProjectSection(ProjectDependencies) = postProject
                {CCEE2530-3384-49B2-B5FB-6C588DF69FF7} = 
{CCEE2530-3384-49B2-B5FB-6C588DF69FF7}
                {CDAEE59D-0373-4F41-9CF9-8DFA13581522} = 
{CDAEE59D-0373-4F41-9CF9-8DFA13581522}
        EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liba", "C:\temp\liba\liba.vcproj", 
"{CCEE2530-3384-49B2-B5FB-6C588DF69FF7}"
        ProjectSection(ProjectDependencies) = postProject
                {CDAEE59D-0373-4F41-9CF9-8DFA13581522} = 
{CDAEE59D-0373-4F41-9CF9-8DFA13581522}
        EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "exeb", "C:\temp\exeb\exeb.vcproj", 
"{01DD3A6A-19F5-4958-92C8-9AE7F300FF50}"
        ProjectSection(ProjectDependencies) = postProject
                {CCEE2530-3384-49B2-B5FB-6C588DF69FF7} = 
{CCEE2530-3384-49B2-B5FB-6C588DF69FF7}
                {CDAEE59D-0373-4F41-9CF9-8DFA13581522} = 
{CDAEE59D-0373-4F41-9CF9-8DFA13581522}
        EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liba", "C:\temp\liba\liba.vcproj", 
"{CCEE2530-3384-49B2-B5FB-6C588DF69FF7}"
        ProjectSection(ProjectDependencies) = postProject
                {CDAEE59D-0373-4F41-9CF9-8DFA13581522} = 
{CDAEE59D-0373-4F41-9CF9-8DFA13581522}
        EndProjectSection
EndProject

As you can see, the dependencies are correct, but liba is generated twice. 
Visual studio complains about duplicates, but it seems to work ok regardless. 
Is this a bug? Am I breaking some unwritten rules here? What about other 
generators, like xcode, ...

thanks
Egon Kocjan
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to