Discussion:
[CMake] exclude build project from solution
Andrea Galeazzi
2011-05-03 14:59:50 UTC
Permalink
I've a project made up of multiple executable target:
add_executable(TARGET_NAME1 ${SOURCES1})
add_executable(TARGET_NAME2 ${SOURCES2})
add_executable(TARGET_NAME3 ${SOURCES3})

...........
Now I'd like to build just only TARGET_NAME1 when I press F7 (build
solution) in visual studio. I tried to add
set_target_properties(TARGET_NAME2 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
set_target_properties(TARGET_NAME3 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
......
but it only remove the dependency from ALL_BUILD project.
So, is it possible to generate a such kind of solution?
Johan Björk
2011-08-01 15:05:50 UTC
Permalink
Hi all,

Anyone know anything about this? I'm seeing the same issue with MSVC 2008 +
cmake 2.8(.?)

add_library(foo .. EXCLUDE_FROM_ALL ..)

-Johan
Post by Andrea Galeazzi
add_executable(TARGET_NAME1 ${SOURCES1})
add_executable(TARGET_NAME2 ${SOURCES2})
add_executable(TARGET_NAME3 ${SOURCES3})
...........
Now I'd like to build just only TARGET_NAME1 when I press F7 (build
solution) in visual studio. I tried to add
set_target_properties(TARGET_**NAME2 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
set_target_properties(TARGET_**NAME3 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
......
but it only remove the dependency from ALL_BUILD project.
So, is it possible to generate a such kind of solution?
______________________________**_________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/**
opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
Johan Björk
2011-08-01 15:15:02 UTC
Permalink
and I just found

The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual studio
generators. If it is set to 1 the target will not be part of the default
build when you select "Build Solution".

Anyone know why it is different from EXLUDE_FROM_ALL ?

-Johan
Post by Johan Björk
Hi all,
Anyone know anything about this? I'm seeing the same issue with MSVC 2008 +
cmake 2.8(.?)
add_library(foo .. EXCLUDE_FROM_ALL ..)
-Johan
Post by Andrea Galeazzi
add_executable(TARGET_NAME1 ${SOURCES1})
add_executable(TARGET_NAME2 ${SOURCES2})
add_executable(TARGET_NAME3 ${SOURCES3})
...........
Now I'd like to build just only TARGET_NAME1 when I press F7 (build
solution) in visual studio. I tried to add
set_target_properties(TARGET_**NAME2 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
set_target_properties(TARGET_**NAME3 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
......
but it only remove the dependency from ALL_BUILD project.
So, is it possible to generate a such kind of solution?
______________________________**_________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/**
opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
Johan Björk
2011-08-01 16:57:36 UTC
Permalink
And another update while at it.

The following cmake file illustrates the issue:

FILE(WRITE foo.c "")
add_library(foo EXCLUDE_FROM_ALL foo.c)
set_target_properties(foo PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
FILE(WRITE foobar.c "")
add_executable(foobar foobar.c)
target_link_libraries(foobar foo)

This works fine in the makefile (and xcode) generator, but fails in MSVC
2008 with
1>------ Skipped Build: Project: foo, Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration
2>------ Build started: Project: foobar, Configuration: Debug Win32 ------
2>Compiling...
2>foobar.c
2>Compiling manifest to resources...
2>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
2>Copyright (C) Microsoft Corporation. All rights reserved.
2>Linking...
2>LINK : fatal error LNK1104: cannot open file 'Debug\foo.lib'
2>Build log was saved at "file://c:\Users\Felix Bruns\Documents\Visual
Studio 2008\Projects\a'\foobar.dir\Debug\BuildLog.htm"
2>foobar - 1 error(s), 0 warning(s)
3>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32
------
3>Project not selected to build for this solution configuration
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 2 skipped ==========

I'll file a bug.
Post by Johan Björk
and I just found
The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual studio
generators. If it is set to 1 the target will not be part of the default
build when you select "Build Solution".
Anyone know why it is different from EXLUDE_FROM_ALL ?
-Johan
Post by Johan Björk
Hi all,
Anyone know anything about this? I'm seeing the same issue with MSVC 2008
+ cmake 2.8(.?)
add_library(foo .. EXCLUDE_FROM_ALL ..)
-Johan
Post by Andrea Galeazzi
add_executable(TARGET_NAME1 ${SOURCES1})
add_executable(TARGET_NAME2 ${SOURCES2})
add_executable(TARGET_NAME3 ${SOURCES3})
...........
Now I'd like to build just only TARGET_NAME1 when I press F7 (build
solution) in visual studio. I tried to add
set_target_properties(TARGET_**NAME2 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
set_target_properties(TARGET_**NAME3 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
......
but it only remove the dependency from ALL_BUILD project.
So, is it possible to generate a such kind of solution?
______________________________**_________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/**
opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
Johan Björk
2011-08-10 00:09:30 UTC
Permalink
Dave, Bill? Anyone know what the difference is intended to be between
EXLUDE_FROM_ALL vs EXCLUDE_FROM_DEFAULT_BUILD?

/Johan
Post by Johan Björk
And another update while at it.
FILE(WRITE foo.c "")
add_library(foo EXCLUDE_FROM_ALL foo.c)
set_target_properties(foo PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
FILE(WRITE foobar.c "")
add_executable(foobar foobar.c)
target_link_libraries(foobar foo)
This works fine in the makefile (and xcode) generator, but fails in MSVC
2008 with
1>------ Skipped Build: Project: foo, Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration
2>------ Build started: Project: foobar, Configuration: Debug Win32 ------
2>Compiling...
2>foobar.c
2>Compiling manifest to resources...
2>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
2>Copyright (C) Microsoft Corporation. All rights reserved.
2>Linking...
2>LINK : fatal error LNK1104: cannot open file 'Debug\foo.lib'
2>Build log was saved at "file://c:\Users\Felix Bruns\Documents\Visual
Studio 2008\Projects\a'\foobar.dir\Debug\BuildLog.htm"
2>foobar - 1 error(s), 0 warning(s)
3>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32
------
3>Project not selected to build for this solution configuration
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 2 skipped ==========
I'll file a bug.
Post by Johan Björk
and I just found
The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual studio
generators. If it is set to 1 the target will not be part of the default
build when you select "Build Solution".
Anyone know why it is different from EXLUDE_FROM_ALL ?
-Johan
Post by Johan Björk
Hi all,
Anyone know anything about this? I'm seeing the same issue with MSVC 2008
+ cmake 2.8(.?)
add_library(foo .. EXCLUDE_FROM_ALL ..)
-Johan
Post by Andrea Galeazzi
add_executable(TARGET_NAME1 ${SOURCES1})
add_executable(TARGET_NAME2 ${SOURCES2})
add_executable(TARGET_NAME3 ${SOURCES3})
...........
Now I'd like to build just only TARGET_NAME1 when I press F7 (build
solution) in visual studio. I tried to add
set_target_properties(TARGET_**NAME2 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
set_target_properties(TARGET_**NAME3 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
......
but it only remove the dependency from ALL_BUILD project.
So, is it possible to generate a such kind of solution?
______________________________**_________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/**
opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
David Cole
2011-08-10 15:04:41 UTC
Permalink
Looks to me like the one chunk of code that actually refers to the
target property:

if(target->GetPropertyAsBool("EXCLUDE_FROM_DEFAULT_BUILD"))
{
return false;
}

should be changed to:

if(target->GetPropertyAsBool("EXCLUDE_FROM_DEFAULT_BUILD") ||
target->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
{
return false;
}

The EXCLUDE_FROM_DEFAULT_BUILD reference has been there since Nov.
2006 in this commit by Bill:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b0bc59f7

EXCLUDE_FROM_ALL is referenced in many, many more places in the code,
but the intent behind the properties seems (to me) to be identical.
We'll see if Bill or Brad objects to this or has additional input....
:-)


David
Post by Johan Björk
Dave, Bill? Anyone know what the difference is intended to be between
EXLUDE_FROM_ALL vs EXCLUDE_FROM_DEFAULT_BUILD?
/Johan
Post by Johan Björk
And another update while at it.
FILE(WRITE foo.c "")
add_library(foo EXCLUDE_FROM_ALL foo.c)
set_target_properties(foo PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
FILE(WRITE foobar.c "")
add_executable(foobar foobar.c)
target_link_libraries(foobar foo)
This works fine in the makefile (and xcode) generator, but fails in MSVC
2008 with
1>------ Skipped Build: Project: foo, Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration
2>------ Build started: Project: foobar, Configuration: Debug Win32 ------
2>Compiling...
2>foobar.c
2>Compiling manifest to resources...
2>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
2>Copyright (C) Microsoft Corporation.  All rights reserved.
2>Linking...
2>LINK : fatal error LNK1104: cannot open file 'Debug\foo.lib'
2>Build log was saved at "file://c:\Users\Felix Bruns\Documents\Visual
Studio 2008\Projects\a'\foobar.dir\Debug\BuildLog.htm"
2>foobar - 1 error(s), 0 warning(s)
3>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32
------
3>Project not selected to build for this solution configuration
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 2 skipped ==========
I'll file a bug.
Post by Johan Björk
and I just found
The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual studio
generators. If it is set to 1 the target will not be part of the default
build when you select "Build Solution".
Anyone know why it is different from EXLUDE_FROM_ALL ?
-Johan
Post by Johan Björk
Hi all,
Anyone know anything about this? I'm seeing the same issue with MSVC
2008 + cmake 2.8(.?)
add_library(foo .. EXCLUDE_FROM_ALL ..)
-Johan
Post by Andrea Galeazzi
add_executable(TARGET_NAME1 ${SOURCES1})
add_executable(TARGET_NAME2 ${SOURCES2})
add_executable(TARGET_NAME3 ${SOURCES3})
...........
Now I'd like to build just only TARGET_NAME1 when I press F7 (build
solution) in visual studio. I tried to add
set_target_properties(TARGET_NAME2 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
set_target_properties(TARGET_NAME3 PROPERTIES EXCLUDE_FROM_ALL "TRUE")
......
but it only remove the dependency from ALL_BUILD project.
So, is it possible to generate a such kind of solution?
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
Loading...