Re: [CMake] Is there analog of source command from bash ?

2017-05-28 Thread Magnus Therning

Denis Kotov <redrad...@gmail.com> writes:

> Hi everyone,
>
> I have tried to find solution to the following problem: There is the
> project with environment variable described in *setenv.sh* file
> Old build process looks like:
> source *setenv.sh*
> make release
>
> But I want to accomplish this by *CMake*. But I have realized that
> *CMake* does not have analog of source command that's why the
> following command does not work:
> execute_process(COMMAND bash -c "source ../setenv")
>
> Because *CMake* creates a child process.
> How can I import variables that was set in some sh file ?

What I usually do is rewrite the sh file into a proper CMake package and
then use find_package() to pull it in. Another option is of course to
just include() it.

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

If our ideas of intellectual property are wrong, we must change them,
improve them and return them to their original purpose. When
intellectual property rules diminish the supply of new ideas, they
steal from all of us.
 — Andrew Brown, November 19, 2005, The Guardian


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] get complete list of compile definitions

2017-04-04 Thread Magnus Therning

Robert Schwarzelt <rschwarz...@gmail.com> writes:

> Hi all,
> I need to implement a code export function, that will only export code used
> in a specific project configuration.
> For this purpose I want to use unifdef (http://dotat.at/prog/unifdef/),
> which is capable of removing unused #ifdef blocks.
>
> The project uses static libraries like in following example:
>
> add_library(
> foo STATIC
> foo.c
> )
>
> add_library(
> bar STATIC
> bar.c
> )
>
> target_compile_definitions(bar INTERFACE HAVE_BAR)
> target_link_libraries(foo LINK_PUBLIC bar)
>
>
> Now foo.c will be compiled with -DHAVE_BAR at build time.
> To create a custom target using unifdef i need this information at cmake
> configure time. I expected to find this in the property COMPILE_DEFINITIONS
> of either the source file foo.c or target foo, but both are empty.
>
> Does anyone know, how to get a list of definitions (that will be used at
> build time) for targets or files?

Not to discourage you, but *every time* I've asked a question along the
lines of "how can I get a list of foo for a source file / target at
cmake configuration time" the answer has been "oh, that's not easy", or
even "oh, that's not possible". In every case I've resorted to trying to
find a way to push what I want to do until build time.

If you *can* find a way to do it post-configuration time I believe you will have
access to everything you need if you set "CMAKE_EXPORT_COMPILE_COMMANDS"
and then look at the resulting `compile_commands.json`.

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Finagle's Second Law:
Always keep a record of data — it indicates you've been working.


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] cmake source tree pollution ?

2016-09-12 Thread Magnus Therning

Bruce Stephens <bruce.r.steph...@gmail.com> writes:

> Looks like https://github.com/redguardtoo/cpputils-cmake might be involved...

If that is the case then this section could be of interest:

https://github.com/redguardtoo/cpputils-cmake#stop-creating-makefiles-for-flymake

/M

-- 
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

The man who is denied the opportunity of taking decisions of
importance begins to regard as important the decisions he is allowed
to take.
 — C Northcote Parkinson


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Testing commands that are intended to fail

2016-06-13 Thread Magnus Therning

John P. Hartmann <jphartm...@gmail.com> writes:

> Excuse me for asking a no doubt obvious question.
>
> The test case (objlink is the executable):
>
> add_test( nullobjlink )
>
> The log:
>
> Output:
> --
> Positional argument(s) missing.  0 specified, 1 required.
> 
> Test time =   0.01 sec
> --
> Test Failed.
>
> Test was actually successful.  I'd like to verify that the return value
> is 8 and that the above message is issued to standard error.  The test
> should fail for any other return value or if anything is written to 
> stdout or if anything else is written to stderr.
>
> Howto, please?

I'd wrap it in a shell script, or use something like shelltestrunner[1].

/M

[1]: http://joyful.com/shelltestrunner/

-- 
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Java is, in many ways, C++--.
 — M Feldman


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] add_custom_command, POST_BUILD

2016-06-01 Thread Magnus Therning

Vladimir Chebotarev <vladimir.chebota...@gmail.com> writes:

> Hi there.
>
> At the moment one can add a command executing after a build of a target
> using:
> add_custom_command(... POST_BUILD...)
>
> However if the command have a dependencies which build after the target,
> there is practically no way to specify it.
>
> Simple case: we have a library and tests for it. E.g. I want them to run in
> POST_BUILD of a library. But, tests already depends on the library so I
> can't make them built before it.
>
> There are few possible solutions to that:
> 1) add possibility to set dependencies for add_custom_command in POST_BUILD
> mode;
> 2) add possibility to populate list of targets if we have specified ones in
> list.
>
> Or maybe correct me if I miss something.

Have you not simply missed add_test()? ;)

What's the reason for wanting the tests to run post-build, rather than
on `make test`?

/M

-- 
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

A system is composed of components: a component is something you
understand.
 — Professor Howard Aiken


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] linking OBJECT libraries : Argument list too long

2016-05-25 Thread Magnus Therning

Biddiscombe, John A. <biddi...@cscs.ch> writes:

> When building OpenBLAS on OSX, the link line generated contains around
> 350K of text, and the max supported arg length is getconf ARG_MAX -
> returns 262144.
> This causes the link phase to abort with Error running link command:
> Argument list too long
>
> The reason for the problem is that many libraries of Type OBJECT are
> built and produce huge numbers of object files are then added to one
> very large list which is then passed to the linker.
>
> I implemented a simple(ish) fix, that doesn't quite work - for each
> subdirectory that generates object files, I set the
> CMAKE_FILES_DIRECTORY and specify the binary directory where the build
> should go using a single character counter 0,1,2,3,4 which is much
> shorter than the target name and it reduces the final arg size down
> almost enough
>
> set(COUNTER_ 0)
> foreach (SUBDIR ${SUBDIRS})
>   set(CMAKE_FILES_DIRECTORY "/${COUNTER_}")
>   add_subdirectory(${SUBDIR} ${CMAKE_BINARY_DIR}/${COUNTER_})
> .
>   MATH(EXPR COUNTER_ "${COUNTER_}+1")
> endforeach ()
>
> example : make driver_level2 target
> [  0%] Building C object 
> OpenBLAS/driver/level2/CMakeFiles/driver_level2.dir/CMakeFiles/ssbmv_U.c.o
> becomes
> [  0%] Building C object 1/CMakeFiles/driver_level2.dir/1/ssbmv_U.c.o
>
> and the link line is correspondingly shorter as the driver_level2 has
> been replaced in 2 places. The problem is that there is still an extra
> "CMakeFiles/driver_level2.dir" in the path to the object file that I
> would like to shorten/remove.
>
> How can I do that?
>
> NB. I am aware that I can turn the OBJECT libraries into normal
> libraries and link them conventionally, but I'd like to make this path
> shortening method work.

Wouldn't a better solution be to use an options file, something like
ld's @file[1]?

/M

[1]: http://linux.die.net/man/1/ld

-- 
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
 — R.P. Feynman


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] How to set link option

2016-04-26 Thread Magnus Therning

vakano <zhon...@proplussolution.com> writes:

> Hi, 
>
> I have some link option as below:
>
> -Wl, -rpath, ${PROJECT_TOP}/dist  ../proj_a/lib_a.a -lb -Wl, --whole-archive
> ../proj_c/lib_c.a

What have you tried?

/M

-- 
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

McBryan's Law: You can't make it better until you make it work.


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

[CMake] C standard and order of arguments

2016-01-12 Thread Magnus Therning

I'm trying to turn on a bit more warnings in a C project but I'm running
into an ordering issue.

I have

#+BEGIN_SRC cmake
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "-Wall -Wextra -Werror")
#+END_SRC

and I want to add ~-Wpedantic~. However if I do then I get a lot of warnings
(that are turned into errors) about breaking C99. In particular:

#+BEGIN_QUOTE
ISO C99 requires at least one argument for the "..." in a variadic macro 
[-Werror]
#+END_QUOTE

This apparently comes from ~-std=gnu11~ (the result of setting
~CMAKE_C_STANDARD~) appearing /after/ the other flags. If I change my
~CMakeLists.txt~ to instead contain

#+BEGIN_SRC cmake
set(CMAKE_C_FLAGS "-std=gnu11 -Wall -Wextra -Wpedantic -Werror")
#+END_SRC

Then I don't get those C99-related warnings. Is there some way to get
~CMAKE_C_STANDARD~ to put ~-std=gnu11~ /before/ the other flags?

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

LeBlanc's law: Later equals never.


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Tests with assert and Release build type

2015-12-24 Thread Magnus Therning

David Cole writes:

> Not only is it possible ... it WILL happen if you use the Microsoft
> C++ compiler and try to mix and match Release and Debug compilation
> units.
>
> The MS compiler has some very nice memory tracking facilities built
> into the Debug runtime libraries, but it is accomplished via different
> structs for Debug and Release builds with extra stuff in the Debug
> structs.

> So allocations from a Debug compilation unit will not be accessed
> correctly in a linked-in Release compilation unit when a pointer to it
> is passed across the boundary.
>
> You will see access violations and hard crashes happening in builds
> from the Microsoft compiler unless you ensure that everything in a
> build has matching Debug/Release defines and compiler settings.
>
> It is only safe to mix-n-match if all calls which cross a boundary
> between compilation units have NO differences in their struct and
> class definitions from an ABI perspective. Since it is difficult to
> verify when this is the case (in general) for large C++ projects, it's
> best to avoid mixing and matching...

I'm *not* mixing stuff built with `-g` and stuff built without it.  I'm
also *not* mixing linking with debug- and non-debug libraries.

I'm only mixing stuff build with `-DNDEBUG` and stuff built without it.

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Software isn't finished until the last user is dead.
-- head on FLOSS Weekly


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Tests with assert and Release build type

2015-12-24 Thread Magnus Therning

Ruslan Baratov writes:

> On 22-Dec-15 04:07, Magnus Therning wrote:
>> Ruslan Baratov writes:
>>
>>> On 20-Dec-15 01:31, Magnus Therning wrote:
>>>> Ruslan Baratov writes:
>>>>
>>>>> How about using RelWithDebInfo? See:
>>>>> http://stackoverflow.com/a/28124715/2288008
>>>> Hmm, I'm probably missing something but how does that solve the issue
>>>> with some targets requiring NDEBUG to be *undefined* and other targets
>>>> requiring NDEBUG to be defined?
>>> I don't think that building targets with different NDEBUG values is a
>>> good idea. More correct approach will be to introduce custom macro to
>>> allow checks (i.e. FOO_NDEBUG/FOO_DEBUG).
>> Why not?
> It is possible to hit situation when ODR will be violated, e.g. if
> somebody define optional member in structure with "#if defined(NDEBUG)"
> condition. Something like this:
> http://stackoverflow.com/questions/20833226/library-headers-and-define

Yes, if we ever start using the NDEBUG macro to control anything in our
code then I'll have to worry about this, as it stands right now it's
only the `assert` from `assert.h` that cares about it.

If I'm reading you correctly you are advocating I simply get rid of the
use of those asserts altogether instead.

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

The results point out the fragility of programmer expertise: advanced
programmers have strong expectations about what programs should look like,
and when those expectations are violated--in seemingly innocuous
ways--their performance drops drastically.
 -- Elliot Soloway and Kate Ehrlich


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Tests with assert and Release build type

2015-12-21 Thread Magnus Therning

Ruslan Baratov writes:

> On 20-Dec-15 01:31, Magnus Therning wrote:
>> Ruslan Baratov writes:
>>
>>> How about using RelWithDebInfo? See:
>>> http://stackoverflow.com/a/28124715/2288008
>> Hmm, I'm probably missing something but how does that solve the issue
>> with some targets requiring NDEBUG to be *undefined* and other targets
>> requiring NDEBUG to be defined?
> I don't think that building targets with different NDEBUG values is a
> good idea. More correct approach will be to introduce custom macro to
> allow checks (i.e. FOO_NDEBUG/FOO_DEBUG).

Why not?

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

We act as though comfort and luxury were the chief requirements of
life, when all that we need to make us happy is something to be
enthusiastic about.
 -- Albert Einstein


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Tests with assert and Release build type

2015-12-19 Thread Magnus Therning

Dave Flogeras writes:

> On Fri, Dec 18, 2015 at 9:55 AM, Magnus Therning <mag...@therning.org> wrote:
>>
>> I'm sure I'm not the first one to run into the conflict between a
>> desire to test the code shipped to customers and the desire to at the
>> same time define NDEBUG to make sure tests don't have their `assert`
>> turned into NOOPs.
>>
>> Is there some nice way of handling this?
>
> I've also wondered this. My solution of choice has always been to keep
> my tests in a subdirectory with a test header like you described:
>
> 
> #fidef NDEBUG
>  #undef NDEBUG
>  #include  // or assert.h for C
>  #define NDEBUG
> #else
>  #include 
> #endif
> 
>
> And include this in each of the unit tests. However, I have found
> sometimes this is not foolproof. In particular I recall on one version
> of OSX one of the system headers would undo this and make assert()
> disappear again, requiring me to play the #include shell game. I
> usually place my "test_assert.hpp" include after all others in the
> unit test, but this is brittle.
>
> I have always just left it as a "good enough" solution, but I too
> would love to hear if someone has a more robust solution.

I did a bit of testing and found that

1. CMAKE_C_FLAGS_* is, very irritatingly, *not* a list, so it's not easy
to remove '-DNDEBUG' from them in the CMakeLists.txt for the tests.

2. Compile options added by target_compile_options() are added *after*
CMAKE_C_FLAGS_* so I settled on using it to pass -UNDEBUG to gcc.

Far from nice, but it works for now (which feels quite typical for CMake).

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

If you can explain how you do something, then you're very very bad at
it.
 -- John Hopfield


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Tests with assert and Release build type

2015-12-19 Thread Magnus Therning

Ruslan Baratov writes:

> How about using RelWithDebInfo? See:
> http://stackoverflow.com/a/28124715/2288008

Hmm, I'm probably missing something but how does that solve the issue
with some targets requiring NDEBUG to be *undefined* and other targets
requiring NDEBUG to be defined?

/M

> On 18-Dec-15 20:55, Magnus Therning wrote:
>> I'm sure I'm not the first one to run into the conflict between a desire
>> to test the code shipped to customers and the desire to at the same time
>> define NDEBUG to make sure tests don't have their `assert` turned into
>> NOOPs.
>>
>> Is there some nice way of handling this?
>>
>> I can always remove -DNDEBUG from the CFLAGS for tests (possibly by
>> defining a new macro, `ADD_EXECUTABLE_TEST()` or something). Another
>> option is to `#undef NDEBUG` in the source of tests.
>>
>> If there's some more or less standard way to address this I'd like to
>> use that.
>>
>> /M
>>
>> --
>> Magnus Therning  OpenPGP: 0x927912051716CE39
>> email: mag...@therning.org   jabber: mag...@therning.org
>> twitter: magthe   http://therning.org/magnus
>>
>> There's a big difference between making something easy to use and
>> making it productive.
>>   -- Adam Bosworth
>>
>>


--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

C++ is history repeated as tragedy. Java is history repeated as farce.
 -- Scott McKay


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

[CMake] Tests with assert and Release build type

2015-12-18 Thread Magnus Therning

I'm sure I'm not the first one to run into the conflict between a desire
to test the code shipped to customers and the desire to at the same time
define NDEBUG to make sure tests don't have their `assert` turned into
NOOPs.

Is there some nice way of handling this?

I can always remove -DNDEBUG from the CFLAGS for tests (possibly by
defining a new macro, `ADD_EXECUTABLE_TEST()` or something). Another
option is to `#undef NDEBUG` in the source of tests.

If there's some more or less standard way to address this I'd like to
use that.

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

There's a big difference between making something easy to use and
making it productive.
 -- Adam Bosworth


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] actually using cmake alternative to convenience libraries

2015-11-18 Thread Magnus Therning
On Tue, Nov 17, 2015 at 09:37:25AM -0600, Jack Stalnaker wrote:
> I'm trying to figure out the best way to handle something that was a
> convenience lib under autotools. I realize that there's a FAQ entry here:
> 
> https://cmake.org/Wiki/CMake_FAQ#Does_CMake_support_.22convenience.22_libraries.3F
> 
> But its terse 2 paragraphs don't say how to actually do what it suggests.
> My problem is this. I have this source tree:
> 
> lib
> |--foo.c
> |--foo.h
> |--bar.c
> |--bar.h
> |--baz.c
> src
> |--goo.c
> 
> In lib, I need to somehow collectively refer to foo and bar. Okay, so I can
> create a variable:
> 
> set(foobarSRCS foo.c bar.c)
> set(foobarLIBS ${externalLibFound})
> 
> which is what the FAQ entry seems to suggest. However, this variable is not
> visible to goo.c. Okay, so as an alternative, I can do this:
> 
> set(foobarSRCS foo.c bar.c PARENT_SCOPE), etc.
> 
> but now the variable is not visible to baz.c, which also must include the
> srcs to create a module library called _baz! I can of course do something
> like this:
> 
> set(foobarSRCSLOC foo.c bar.c)
> set(foobarSRCS ${foobarSRCSLOC} PARENT_SCOPE)
> 
> but this feels dirty and repetitive.
> 
> I also realize that I can just create the variables in src, but that kind
> of defeats the entire purpose of walling of the common libs and their
> dependencies in the first place.
> 
> Is this the right way to work, or am I missing something simple?

From your text above it sounds like foo.{c,h} and bar.{c,h} don't really
belong together with baz.c (it's not part of the convenience lib).  So,
why not separate them?

Another thought, you can always put a CMakeLists.txt in the parent dir
to lib with

set(foobarSRCS lib/foo.c lib/bar.c)

(maybe with the use of CMAKE_CURRENT_SOURCE_DIR too).

A final questin, why was it a convenience lib in the autotools setup?
Unless there's really a need to compile the files multiple times the
whole issue can be side stepped by making it a static lib.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

As we enjoy great advantages from the inventions of others we should
be glad of an opportunity to serve others by any invention of
ours, and this we should do freely and generously.
 -- Benjamin Franklin


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] actually using cmake alternative to convenience libraries

2015-11-18 Thread Magnus Therning
On Wed, Nov 18, 2015 at 08:16:39AM -0600, Jack Stalnaker wrote:
> In the real source code, baz is a thin wrapper for the foo/bar lib. It
> combines them into a Python module library, and doesn't really contain
> any substantial code of its own.

Ah, that justifies its location then :)

> As for the last suggestion, I was specifically trying to avoid listing
> the sources in the top level CMakeLists.txt file. To me, that pollutes
> the top-level file with stuff it shouldn't care about. In the likely
> event that I have to change the contents of src or lib, I have to
> change the top-level CMakeLists, which seems non-intuitive.

What about using `include()` to bring the variables into the top-level
(or really any level)?  (Do note I haven't thought that suggestion
through properly!)

> I realize all of this sounds incredibly pedantic, since I've found so
> many workarounds by now, but I guess I'm trying to get to the bottom
> of the CMake crew's vision of how what used to be convenience libs in
> autotools should work in CMake. The idea of smashing together a set of
> common objects and their dependencies into a convenient partially
> compiled/linked block and passing it around without installing it just
> seems so, well, convenient and clean, and I am trying to envision the
> alternative since otherwise cmake seems so convenient and clean
> compared to autotools.

Oh, how I recognize that feeling. :)  Sometimes CMake feels clean and
convenient, and then all of a sudden one has to start thinking about
what's available at which state and frustration grows...  I guess build
systems are a bit like mail readers, they all suck, one just have to
find one that sucks less than the previous one used.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

If voting could really change things it would be illegal.


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

[CMake] Running a C source file through the pre-processor

2015-11-15 Thread Magnus Therning
I have a tool that, given a C source file, spits out some linker flags
that's necessary to link the file into the final target.  Now the C
source file has grown rather large and I'd like to split some of it into
a header file (those things are also useful in other files to reducing
duplication of code is another reason to do this).  This however means
that it's not enough to pass the C source file through the tool, I need
to pass the pre-processed source to the tool!

The question is then if I can do this easily in some way?

I was thinking of doing it manually so to speak, but then I quickly ran
into the problem of finding the effective CFLAGS used for a
source/target.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Finagle's Sixth Law:
Don't believe in miracles -- rely on them.


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

[CMake] DESTDIR and ExternalProject

2015-10-09 Thread Magnus Therning
How can I refer to an environment variable in a generator-agnostic way?


I'm struggling with constructing a functioning install command when
using ExternalProject.  I want to allow the following sequence of
commands:

% cmake ..
% make
% make DESTDIR=foo install

The issue I run into is that I somehow have to pass DESTDIR from the
environment into the install command of my ExternalProject, but how do I
do that?

$ENV{DESTDIR} gets expanded at generation time, which is too early.  I
can use $(DESTDIR), CMake happily passes that through and it works with
GNU make.  However, it doesn't work with e.g. Ninja (to pick just one).

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Don't worry about other people stealing your ideas. If your ideas are
any good, you’ll have to ram them down people's throats.
 -- Howard Aiken, IBM Engineer


signature.asc
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Settings different flags in sub projects

2014-08-03 Thread Magnus Therning
On Sun, Aug 03, 2014 at 05:46:40PM -0500, David Zemon wrote:
 Hello,
 
 For the simple case of three directories and two projects - /root, /root/p1,
 and /root/p2 - I would like to set some common flags for both projects and
 then other flags should be independent. For instance, p1 should be compiled
 with -std=c99 -Os and p2 should be compiled with -std=c99 -O1. The first
 flag, -std=c99, is common to all projects and the second, -Os, might be
 changed from project to project. How do I do this?
 
 I thought I could create MyRulesOverride.cmake with the content:
 
set(CMAKE_C_FLAGS_INIT -std=c99)
 
 And that would be the end of it, but apparently not. The CMakeLists.txt
 files in each project have a line such as  set(CMAKE_C_FLAGS -Os) which
 is apparently overwriting the cached value from CMakeCInformation.cmake. I
 can't write a line like set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Os) because
 then the result is -std=c99 -std=c99 -Os for the second project.
 
 Any help would be greatly appreciated.

I haven't tested this, but would you have to *add* to the flag?  AFAIU
setting always over writes the previous value.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

The results point out the fragility of programmer expertise: advanced
programmers have strong expectations about what programs should look like,
and when those expectations are violated--in seemingly innocuous
ways--their performance drops drastically.
 -- Elliot Soloway and Kate Ehrlich


pgpQosC5nlS6D.pgp
Description: PGP signature
-- 

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://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Build cmake child project from cmake parent project

2014-02-19 Thread Magnus Therning
On Wed, Feb 19, 2014 at 06:24:44PM -0500, Aaron Boxer wrote:
 I have cmake two projects, with project 2 added as a git submodule in
 project 1.
 
 I would like to build project 2 from project 1.
 
 How can I do this? I tried add_subdirectory, but this is just for adding
 source directories. I want to use the project 2 cmake files to build it.

Have a look at ExternalProject
(http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:ExternalProject)
it's very likely what you are looking for.

/M


-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
 -- Alan Kay


pgpQWILVXAHlJ.pgp
Description: PGP signature
-- 

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

Re: [CMake] Provide 64bit Linux binaries

2014-01-08 Thread Magnus Therning
On Wed, Jan 08, 2014 at 01:56:22PM +0100, Andreas Pakulat wrote:
 Hi,
 
 I know this has been raised in the past, but I don't think the
 arguments for not providing the binaries are strong enough to
 warrant the hassle a cmake user has to go through to run the 32bit
 binaries on a 64bit Linux distribution.
 
 I think requiring users to figure out how to install 32bit compat
 libraries and keeping a copy of at least libc on the machine for no
 other purpose than running cmake does not really fit the intention
 of providing binaries in the first place. As far as I understand the
 idea was to make it easier for people who cannot upgrade a
 package-manager-provided CMake (for whatever reason) to use a newer
 CMake. Requiring those people to build from source does not really
 make it easy and not all distributions install 32bit compat
 libraries out of the box (let alone older machines which have no
 such compat libs at all)
 
 So can we please get 64bit Linux binaries for the next CMake
 release?

What 64-bit Linux distribution, that doesn't package CMake, do you
use?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Unreadable code,
Why would anyone use it?
Learn a better way.
 -- Geoff Kuenning's contribution to the 2004 Perl Haiku Contest,
Haikus about Perl - 'Dishonerable Mention' winner


pgp67m1IxiNo6.pgp
Description: PGP signature
--

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

Re: [CMake] (no subject)

2014-01-02 Thread Magnus Therning
On Thu, Jan 02, 2014 at 12:14:38AM -0500, Matt Wilbur wrote:
 With a bit of thought and source code reading, I sorted this out.
 Let me know if you'd like me to post my answer to my own question.

Yes, please do.

I'm sure you've found yourself in the very irritating situation where
you're looking for the answer to some question, but all you can find
is other people asking the same question in various fora.  By
answering your own question you'll help other people avoid that
irritating situation when they are looking around for an answer to
this particular question. :)

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
 -- Alan Kay


pgplTa5tYVr0J.pgp
Description: PGP signature
--

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

Re: [CMake] building 64bit and 32bit libraries from same source

2013-12-11 Thread Magnus Therning
On Wed, Dec 11, 2013 at 11:44 PM, Jacob Avraham
jacob.avra...@compass-eos.com wrote:
 Hi,
 I'm running on a 32bit Linux and I'd like to build from the same source, 
 libraries complied and linked as 32bit and 64bit.
 They should be installed in /usr/lib and /usr/lib64.
 How do I go about and do that?

Personally I've never tried to build a 64-bit app/lib on a 32-bit
machine, only the other way around.  Looking at the packages available
for my favourite Linux distribution (ArchLinux) there doesn't seem to
be a compiler that could go the way you want.  It should be possible
though, you just need to get your hands on a compiler:
http://stackoverflow.com/questions/7582218/gcc-compile-a-64-bit-binary-on-32-bit-platform

So, the easiest way in CMake would be to create different folders and
then generate makefiles/ninjafiles/whatever with different CFLAGS
settings.

/M
--

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


Re: [CMake] Making cmake automatically pick up changes to directory contents.

2013-12-03 Thread Magnus Therning
On Tue, Dec 03, 2013 at 11:21:17AM -0500, Bill Hoffman wrote:
 On 12/3/2013 8:58 AM, bi...@billw.mail1.co.uk wrote:
 reasonable to expect them to manage enormous (1800+) file lists
 when we already have a directory structure in place the designates
 project file lists. Hence the GLOBing (my various Googlings for
 the issue shows that I'm definitely not the only one trying to
 work like this).

 Why not write a script that does the GLOB once and creates
 CMakeLists.txt files that have the explicit lists.  It is not like
 the developers will be adding/removing 1000s of files at a time.  It
 will be one or two files at a time, and you won't have to do any
 crazy stuff to get CMake to work with glob.   Once you have the
 cmake files with the explicit list it is done, and that part can be
 done with python/bat/cmake/ any scripting language.

With a proper editor you can even do while writing the CMakeLists.txt
file.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

If you can explain how you do something, then you're very very bad at
it.
 -- John Hopfield


pgpD5YBUuhlNb.pgp
Description: PGP signature
--

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

Re: [CMake] Build application suite with dependency checking but single shared libraries without it

2013-12-01 Thread Magnus Therning
On Sun, Dec 01, 2013 at 01:02:16AM +0100, Tim Grothe wrote:
 Hi Cmakers,
 
 I'm new to CMake and because every new technology is a bit tricky at
 first, I hope some of you can give me a hint with the following
 build scenario.
 
 Operating System: Windows
 
 There are three directories on the same filesystem hierarchy.
 
 - Include-directory
 - Lib-directory
 - Subversion-workingcopy
 
 The workingcopy contains around 80 applications and like 900 shared
 libraries and all of those applications can make use of all shared
 libraries and form together one application suite.
 
 What I'd like to accomplish are the following two scenarios combined
 in one CMake configuration (if possible):
 
 1) Build the complete application suite with automatic dependency
resolving.
 
 For this scenario I would think that I put a CmakeLists.txt to every
 folder hierarchy in the workingcopy and add all the necessary
 folders with add_subdirectory(). Because of the many shared
 libraries and the somewhat complex folder-hierarchy I'm not that
 sure about how to manage the dependencies (probably find_package())
 but this should not be the question now.  The header files, libs and
 the binaries should be stored in the Include-Directory,
 Lib-Directory and a binary directory on the same level like the
 other two directories.
 
 2) Build a shared library or application on it's own without
dependency checking.
 
 Every shared library and every application is an independent
 project.  When building one of these projects the Include-Directory
 and the Lib-Directory should be used when compiling and linking but
 if a dependency is missing or a lib file is out of date this should
 result in a build error in this scenario and the developer has to
 take care of this situation by himself. The created binaries and
 libs should be stored in a subdirectory of the corresponding
 project.
 
 So I've got an idea about how to solve 1) but I have no idea how to
 solve 2) especially in combination with 1).

Well, what you ask for is, I think, exactly the kind of thing that
CMake is designed to do.  However, given the size of the source base
I'd suggest you initially make it a bit more manageable by identifying
a self-contained subset of one app and the libraries it depends on.
Once you've done that it should be easy to see how to scale it up to
cover the entire project.

/M


-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Sendmail and make are two well known programs that are pretty widely
regarded as being debugged into existence. That's why their command
languages are so poorly thought out and difficult to learn.  It's not
just you -- everyone finds them troublesome.
 -- Peter van der Linden, Expert C Programming, p. 220


pgpDNKmjH8gh_.pgp
Description: PGP signature
--

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

Re: [CMake] Problem using CMake for cross compiling for linux

2013-11-28 Thread Magnus Therning
On Thu, Nov 28, 2013 at 04:05:18PM +0100, Thomas Baag wrote:
 Hi folks,
 
 i'm trying to cross compile a simple hello world on Scientific Linux 6.4 
 (amd64) using cmake version 2.8.4 and arm-none-eabi-gcc 4.8.1. I've 
 encountered the well known -rdynamic problem[1], but couldn't manage to 
 apply a nice workaround.
 
 I DONT want to disable simple compiler checks. The problem seems to be in the 
 __linux_compiler_gnu macro in Modules/Platform/Linux-GNU.cmake.
 
 Until now i tried 
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
 SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS )
 before and after PROJECT(...), but it didn't work.
 After that, I added this on top of my CMakeList.txt:
 SET(__LINUX_COMPILER_GNU 1)
 MACRO(__linux_compiler_gnu lang)
  SET(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS )
 ENDMACRO()
 But it also didnt work.
 
 Now i'm somehow out of ideas. Could anyone pls help?
 
 
 Greetings
 Thomas
 
 [1] http://www.cmake.org/Bug/view.php?id=9985
 
 
 
 # Minimal CMakeList.txt:
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
 SET(__LINUX_COMPILER_GNU 1)
 MACRO(__linux_compiler_gnu lang)
  SET(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS )
 ENDMACRO()
 
 PROJECT(Build-Example)
 
 
 # Minimal toolchain file:
 SET(CMAKE_SYSTEM_NAME Linux)
 SET(CMAKE_SYSTEM_PROCESSOR armv7)
 SET(CMAKE_C_COMPILER arm-none-eabi-gcc)

The only way I found around this was

set(CMAKE_SYSTEM_NAME Generic )

but I think that is exactly what you want to avoid given your comment
about I DONT want to disable simple compiler checks.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Unix is the answer, but only if you phrase the question very
carefully.
 -- Unknown


pgpBDnZcXAf0H.pgp
Description: PGP signature
--

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

Re: [CMake] path levels in TGZ cpack generator

2013-11-23 Thread Magnus Therning
On Fri, Nov 22, 2013 at 03:54:38PM +0100, Tino Keitel wrote:
 Hi,
 
 for integration in an existing build infrastructure, I want to use
 cpack with the TGZ generator to create packages that have the
 current directory (./) as the first path component. The content of
 the archive would look like this:
 
 $ tar tf test.tar.gz
 ./x/
 ./x/foo
 
 cpack currently creates packages without this component, such that
 the archive looks like this:
 
 $ tar tf test.tar.gz
 x/
 x/foo
 
 How can I configure cpack to create archives with a directory
 structure like in the first example above?

I may be missing something, but from the view of the unpacker of the
TGZ-ball the two are equivalent, right?  So why do you prefer the
'./x/...' over 'x/...'?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
 -- Alan Kay


pgpGP8pdi7dJu.pgp
Description: PGP signature
--

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

Re: [CMake] ExternalProject BUILD_COMMAND and Visual Studio Express 2010

2013-11-23 Thread Magnus Therning
On Fri, Nov 22, 2013 at 08:49:07PM -0700, Macumber, Daniel wrote:
 Our project is using ExternalProject_Add to build Ruby.  Our
 BUILD_COMMAND on Windows is cd
 ${CMAKE_BINARY_DIR}/Ruby-prefix/src/Ruby-build  nmake.  This
 works using the professional versions of Visual Studio.  However,
 using Visual Studio Express 2010 I get an error that nmake is not a
 known program.  Nmake is not in my system path but is found when
 running the Visual Studio command prompt.  How can I get the
 ExternalProject build command to use the correct environment?
 Should I put a call to vcvarsall.bat in the command line?  Is there
 a CMake variable that has the path to that?

I would expect that you need to put the folder where nmake.exe lives
in the %PATH%, the easiest way of achieving that is probably to use
vcvarsall.bat.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

You do not examine legislation in the light of the benefits it will
convey if properly administered, but in the light of the wrongs it
would do and the harms it would cause if improperly administered.
 -- Lyndon Johnson


pgpwnEMwzTB4V.pgp
Description: PGP signature
--

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

Re: [CMake] ExternalProject BUILD_COMMAND and Visual Studio Express 2010

2013-11-23 Thread Magnus Therning
On Sat, Nov 23, 2013 at 08:54:24AM -0700, Macumber, Daniel wrote:
 Thanks Magnus, is there a reliable way to get the path to
 vcvarsall.bat that will work for various versions of Visual Studio
 (express or not)?

I don't know of any sure way of doing that, but if vcvarsall.bat is
located in the same relative place across all versions of VS then it
might be possible to sort of misuse some variable that CMake sets.

I had a quick look in one project I build with VS2010 and found one
candidate variable: CMAKE_LINKER.

  CMAKE_LINKER   = C:/Program Files (x86)/Microsoft Visual Studio 
10.0/VC/bin/link.exe
  vcvarsall.bat location = C:/Program Files (x86)/Microsoft Visual Studio 
10.0/VC/vcvarsall.bat

I'd consider that a terrible hack though, so hopefully there's someone
else with a better idea.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Beauty is more important in computing than anywhere else in technology
because software is so complicated. Beauty is the ultimate defence
against complexity.
 -- David Gelernter


pgp_OVhWqjn8G.pgp
Description: PGP signature
--

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

Re: [CMake] ExternalData on unmounted Windows shares?

2013-11-18 Thread Magnus Therning
sheepishlyIt does indeed work properly, once one uses the correct
path in all places./sheepishly

Sorry for the noise!

/M

On Fri, Nov 15, 2013 at 11:02 PM, Magnus Therning mag...@therning.org wrote:
 On Fri, Nov 15, 2013 at 04:45:23PM -0500, Brad King wrote:
 On 11/15/2013 04:17 PM, Magnus Therning wrote:
  I just reproduced it locally.  Here's what I did:

 I tested with a local share and corresponding url template:

  file:127.0.0.1/share$/%(algo)/%(hash)

 It downloads at build time successfully for me.

  4. Move the generated SHA file to C:\devo\shared$\SHA256\, in my case it 
  became
 
  C:\devo\shared$\SHA26\9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc

 That should be SHA256, not SHA26.

 That was a typo in my email, it's SHA256 in the file system.

 -- Fetching 
 file:127.0.0.1/shared$/SHA256/9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc
  CMake Error at C:/Program Files (x86)/CMake 
 2.8/share/cmake-2.8/Modules/ExternalData.cmake:717 (message): Object
 SHA256=9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc not 
 found at:

 file:127.0.0.1/shared$/SHA256/9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc
  (couldn't read a file:// file)

 Is the mount available without any required credentials?
 Load it in explorer as

  \\127.0.0.1\shared$\SHA256

 first to be sure.

 No credentials are required, but I found another typo in my
 CMakeLists.txt.  Fixing that made it work for me too.

 I still need to check this a second time at work though.  There the
 setup of shares is a bit more complicated (using MSDFS and such), it
 also does require credentials.

 /M

 --
 Magnus Therning  OpenPGP: 0xAB4DFBA4
 email: mag...@therning.org   jabber: mag...@therning.org
 twitter: magthe   http://therning.org/magnus

 If you can explain how you do something, then you're very very bad at
 it.
  -- John Hopfield



-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

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


Re: [CMake] ExternalData on unmounted Windows shares?

2013-11-15 Thread Magnus Therning
On Wed, Nov 13, 2013 at 10:26:53AM -0500, Brad King wrote:
 On 11/13/2013 03:59 AM, Magnus Therning wrote:
 On Tue, Nov 12, 2013 at 5:09 PM, Brad King brad.k...@kitware.com wrote:
 Add to ExternalData_URL_TEMPLATES the entry

  file:share.host/foo/bar/%(algo)/%(hash)
 
 That still fails on the real path I have to use in the project.
 Are there any known issues with  hidden shares (name ending in $),
 or with paths containing spaces?
 
 The path that fails contains both :(
 
 I just tried network paths containing both spaces and a $ at the end
 or in the middle.  It works just fine for me in either variable.

I just reproduced it locally.  Here's what I did:

1. Create a local share at C:\devo\shared$\

2. Place the following in C:\devo\cmake_test\CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.12)
project(cmake-test)

include(ExternalData)

set(ExternalData_LINK_CONTENT SHA256)
set(ExternalData_URL_TEMPLATES file:127.0.0.1/shared$/%(algo)/%(hash))

ExternalData_Expand_Arguments(binfile binfilevar
DATA{files/vc_web.exe}
)
ExternalData_Add_Target(binfile)

3. Run configure in the CMake GUI tool with

Source location: C:\devo\cmake_test
Build location: C:\devo\cmake_test\_build

4. Move the generated SHA file to C:\devo\shared$\SHA256\, in my
   case it became


C:\devo\shared$\SHA26\9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc

5. Generate for Visual Studio 2010 (all prior attempts have been with
   2012 though so that ought to produce the same issue, but I don't
   have access to VS2012 at home)

6. Start Visual Studio with the generated solution and build 'binfile'

The result I get then is:


-- Build started: Project: ZERO_CHECK, Configuration: Debug Win32 --
-- Build started: Project: binfile, Configuration: Debug Win32 --
  Generating C:/devo/cmake_test/_build/files/vc_web.exe
  -- Fetching 
file:127.0.0.1/shared$/SHA256/9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc
  CMake Error at C:/Program Files (x86)/CMake 
2.8/share/cmake-2.8/Modules/ExternalData.cmake:717 (message):
Object
SHA256=9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc not
found at:
  
  
file:127.0.0.1/shared$/SHA256/9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc
 (couldn't read a file:// file)
  Call Stack (most recent call first):
C:/Program Files (x86)/CMake 
2.8/share/cmake-2.8/Modules/ExternalData.cmake:739 
(_ExternalData_download_object)
  
  
C:\Program Files 
(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error 
MSB6006: cmd.exe exited with code 1.
== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==


 - It's not possible to set only ExternalData_OBJECT_STORES, one has
   to set ExternalData_URL_TEMPLATES too.
 
 Back when this module was part of another project and not ported to
 CMake upstream we did not have ExternalData_OBJECT_STORES and always
 used a store in the build tree.  That is why
 ExternalData_URL_TEMPLATES is required to be set.  When the
 ExternalData_OBJECT_STORES capability was created no one thought to
 lift the ExternalData_URL_TEMPLATES requirement because the projects
 using the module all set it anyway.
 
 It is easy enough to lift that restriction:
 
  ExternalData: Allow local stores without any URL templates
  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8eb20eea

Excellent, I hope that's slated for the next release then :)

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Most software today is very much like an Egyptian pyramid with
millions of bricks piled on top of each other, with no structural
integrity, but just done by brute force and thousands of slaves.
 -- Alan Kay


pgpK2dAaM1vH_.pgp
Description: PGP signature
--

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

Re: [CMake] ExternalData on unmounted Windows shares?

2013-11-15 Thread Magnus Therning
On Fri, Nov 15, 2013 at 04:45:23PM -0500, Brad King wrote:
 On 11/15/2013 04:17 PM, Magnus Therning wrote:
  I just reproduced it locally.  Here's what I did:
 
 I tested with a local share and corresponding url template:
 
  file:127.0.0.1/share$/%(algo)/%(hash)
 
 It downloads at build time successfully for me.
 
  4. Move the generated SHA file to C:\devo\shared$\SHA256\, in my case it 
  became
  
  C:\devo\shared$\SHA26\9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc
 
 That should be SHA256, not SHA26.

That was a typo in my email, it's SHA256 in the file system.

 -- Fetching 
 file:127.0.0.1/shared$/SHA256/9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc
  CMake Error at C:/Program Files (x86)/CMake 
 2.8/share/cmake-2.8/Modules/ExternalData.cmake:717 (message): Object 
 SHA256=9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc not 
 found at:
 
 file:127.0.0.1/shared$/SHA256/9cf657b2a8e4a3deec1aa820dd60540d000bf1e6a5ae84920e93d698c293b2fc
  (couldn't read a file:// file)
 
 Is the mount available without any required credentials?
 Load it in explorer as
 
  \\127.0.0.1\shared$\SHA256
 
 first to be sure.

No credentials are required, but I found another typo in my
CMakeLists.txt.  Fixing that made it work for me too.

I still need to check this a second time at work though.  There the
setup of shares is a bit more complicated (using MSDFS and such), it
also does require credentials.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

If you can explain how you do something, then you're very very bad at
it.
 -- John Hopfield


pgpPah8bxa_fD.pgp
Description: PGP signature
--

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

Re: [CMake] ExternalData on unmounted Windows shares?

2013-11-13 Thread Magnus Therning
On Tue, Nov 12, 2013 at 5:09 PM, Brad King brad.k...@kitware.com wrote:
 On 11/12/2013 08:43 AM, Magnus Therning wrote:
 Is there some way to point to an unmounted Windows share?

 Add to ExternalData_URL_TEMPLATES the entry

  file:share.host/foo/bar/%(algo)/%(hash)

That still fails on the real path I have to use in the project.  Are
there any known issues with  hidden shares (name ending in $), or with
paths containing spaces?

The path that fails contains both :(

 Since it is accessible through filesystem APIs you could also
 set ExternalData_OBJECT_STORES to

  c:/some/local/store;//share.host/foo/bar

 That tells ExternalData to use objects found in the local store
 or the network path directly without downloading.  If an object
 is not found in either path, then the url templates will be
 searched for the object and it will be downloaded to the local
 store (first entry in ExternalData_OBJECT_STORES).

That's what I was testing and wrote about in another response on this thread:

- It's not possible to set only ExternalData_OBJECT_STORES, one has to
set ExternalData_URL_TEMPLATES too.
- I'd like to not have to map the drive (other users of the project
would then have to free up a specific drive letter) and
ExternalData_OBJECT_STORES don't seem to handle paths of the form
//share.host/foo/bar.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

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


Re: [CMake] Keep folder structure in Visual Studio Project generated with CMake

2013-11-12 Thread Magnus Therning
When I am forced to use VS for development work I tend to only use it
as an editor and bild tool, i.e. I don't create files in it or add
things to the project.  Instead the sequence I use to add a file is:

1. touch the file I want created
2. modify the relevant CMakeLists.txt to include the generated file
3. re-generate the VS solution and projects files (either by running
CMake directly or by building inside VS)
4. answer 'yes' to all questions about reloading solution and projects in VS
5. open the file, which now will have appeared in the solution explorer in VS
6. hack away

It's maybe a few too many steps for someone used to working with only
VS, but the power, happiness, and bliss of using CMake doesn't come
completely free ;)

/M


On Tue, Nov 12, 2013 at 11:44 AM, Luca Gherardi luca.ghera...@unibg.it wrote:
 I have a projects in which the sources file are organizes in a hierarchy of
 directories.

 For example:

 - Src

 | - Folder A

| - 1.cpp

| - 1.hpp

| - FolderA1

   | - 2.cpp

   | - 2.hpp

 | - Folder B

| - 3.cpp

| - 3.hpp





 I wrote a CMakeLists.txt for generating a Visual Studio Projects (VS 2012).



 My goals are the following:

 -Preserve the directory structure

 -Allows other developer to add source files in the directory, by
 means of visual studio, without having to write CMakeLists.txt



 For doing that I wrote the following CMakeLists.txt



 cmake_minimum_required(VERSION 2.8.11)

 project(Common-library CXX)

 #set the default path for built executables to the bin directory

 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

 #set the default path for built libraries to the lib directory

 set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)



 #Specify my Include Directory

 set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src)



 # Boost configuration

 SET(Boost_USE_STATIC_LIBS ON)

 find_package(Boost REQUIRED COMPONENTS filesystem system thread REQUIRED)



 include_directories( ${Boost_INCLUDE_DIRS} ${ PROJECT_INCLUDE_DIR} )



 # I used this for allowing CMake to include all the files,

 # also new ones, without having to touch the CMakeLists.txt

 file(GLOB_RECURSE PROJECT_SOURCE_FILES *.h *.hpp *.cpp)



 # I then wrote this Macro, which organize the files in visual studio
 folders,

 # according to the organization in the file systems



 macro(GroupSources curdir)

file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir}
 ${PROJECT_SOURCE_DIR}/${curdir}/*)

foreach(child ${children})

   if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})

   GroupSources(${curdir}/${child})

   else()

   string(REPLACE / \\ groupname ${curdir})

   # I would like to call the src root folder in a different name,
 only in visual studio (not mandatory requirement)

string(REPLACE src Common groupname ${groupname})

 source_group(${groupname} FILES
 ${PROJECT_SOURCE_DIR}/${curdir}/${child})

   endif()

endforeach()

 endmacro()



 # Execute the macro

 GroupSources(src)



 add_library(${PROJECT_NAME} ${ PROJECT_SOURCE_FILES})





 The result is a Visual studio project which organizes the files as I
 desired.

 However when I try to create new files with visual studio they are not
 stored in the folder I select, but in the out-of-source build folder.

 I guess this is due to the fact that visual studio doesn’t now the mapping
 between src folder and source group.



 How can I achieve both my goals?



 Thanks in advace!


 --

 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



-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

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

[CMake] ExternalData on unmounted Windows shares?

2013-11-12 Thread Magnus Therning
I'm trying to put some large-ish data files on a windows share and
then reference them using the ExternalData module.  I'm running into
problems setting the ExternalData_URL_TEMPLATES properly.  Neither
smb://share.host/foo/bar/%(algo)/%(hash) nor
//share.host/foo/bar/%(algo)/%(hash) work.  For the former
ExternalData reports

  unsupported protocol

and for the latter

  URL using bad/illegal format or missing URL

Is there some way to point to an unmounted Windows share?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

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


Re: [CMake] ExternalData on unmounted Windows shares?

2013-11-12 Thread Magnus Therning
On Tue, Nov 12, 2013 at 3:06 PM, Jakub Zakrzewski jzakrzew...@e2e.ch wrote:
 Did you try: \\share.host/foo/bar/%(algo)/%(hash)? (probably you gonna need 
 proper escaping).
 Note, that UNC paths begin with \\ and in this case they cannot be 
 substitued with //. Also - this is windows-only.

This is all rather interesting, and does look a bit broken to me.

The setup:

A file, foo.img with SHA256
b05528ba594ae4d6ca2b7b76ce02694e19a1c6d9d51b507e7b63d1919cb86e94.  I
copy it to 
smb://share.host/foo/bar/SHA256/b05528ba594ae4d6ca2b7b76ce02694e19a1c6d9d51b507e7b63d1919cb86e94.
 Then map R: to smb://share.host/foo.

I put the following into my CMakeLists.txt:


set(ExternalData_LINK_CONTENT SHA256)
ExternalData_Expand_Arguments(fooimg fooimg_loc
DATA{bin/foo.img}
)
ExternalData_Add_Target(fooimg)


Now, I try combinations of values for ExternalData_URL_TEMPLATES and
ExternalData_OBJECT_STORES:

Not working:

list(APPEND ExternalData_URL_TEMPLATES share.host/foo/bar/%(algo)/%(hash))

The file is not found.

Working:

list(APPEND ExternalData_URL_TEMPLATES share.host/foo/bar/%(algo)/%(hash))
list(APPEND ExternalData_OBJECT_STORES r:/bar)

The file is apparently found (at least there's no complaint) but then
taken from the store.

Not working:

list(APPEND ExternalData_URL_TEMPLATES share.host/foo/bar/%(algo)/%(hash))
list(APPEND ExternalData_OBJECT_STORES share.host/foo/bar)

The file is not found.

Not working:

list(APPEND ExternalData_OBJECT_STORES r:/bar)

Complains that ExternalData_URL_TEMPLATES is empty.

I was surprised to find that ExternalData_URL_TEMPLATES and
ExternalData_OBJECT_STORES weren't more independent and it's
disappointing to find that it isn't possible to use an UNC path to
download a data object.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

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


[CMake] External MS Project and setting active configuration

2013-11-11 Thread Magnus Therning
Hi,

I'm trying to work out how to use include_external_msproject()
properly.  What I have so far isn't quite correct without a bit of
manual configuration in VS after generating the solution+project
files, which isn't quite the way I want it, of course.

What I'm struggling with is connecting the msproject with an imported
lib.  I currently have:

include_external_msproject(msproj
${CMAKE_CURRENT_SOURCE_DIR}/msproj/mymsproj.vcxproj)
add_library(mslib STATIC IMPORTED)
set_property(TARGET mslib
PROPERTY MAP_IMPORTED_CONFIG_Debug LibDebug
PROPERTY IMPORTED_LOCATION_Debug ${CMAKE_BINARY_DIR}/LibDebug/mymsproj.lib
)

Hopefully it's obvious what I'm trying to achieve here, i.e.

  - I have a VS project in msproj/mymsproj.vcxproj (it gets included
properly, and it builds as it should)
  - The VS project defines a number of configurations,
Debug/Release/etc, but at the moment I'm only interested in the
LibDebug configuration and I want the CMake-config Debug to map to the
VS-project-config LibDebug
  - For the VS-project-config LibDebug the build output does end up in
the location mentioned

On running CMake all projects end up in the VS-project-config Debug
(which is default for CMake), but I did expect the above to put
mymsproj in the VS-project-config LibDebug.  What am I doing wrong
here?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

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


Re: [CMake] ExternalProject_Add examples

2013-10-24 Thread Magnus Therning
On Thu, Oct 24, 2013 at 09:04:25PM +0100, Fraser Hutchison wrote:
 There's a StackOverflow answer I did a while back which gives an example of
 ExternalProject_Add for GTest: http://stackoverflow.com/a/9695234/2556117
 
 It maybe needs updated, and I don't think I ever tried it on OSX, but it
 should hopefully be an OK starting point.  (If not - hack away at my
 answer!)

There's also a recent thread of mine on this list that's at least
slightly related:

http://www.cmake.org/pipermail/cmake/2013-October/056086.html

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Time is a great teacher, but unfortunately it kills all its pupils.
 -- Hector Louis Berlioz


pgpg6xzorizx3.pgp
Description: PGP signature
--

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

Re: [CMake] Faking a library

2013-10-19 Thread Magnus Therning
On Wed, Oct 16, 2013 at 11:36:53PM +0200, Alexander Neundorf wrote:
 On Wednesday 16 October 2013, Magnus Therning wrote:
 When defining a library via add_library() it's possible to link
 against it by just putting its name into target_link_libraries().
 Is there some way of wrapping up an external library in a similar
 way?
 
 As a concrete example I'm playing around with gtest[1] via
 externalproject_add() like this:
 
 externalproject_add(gtest
 SOURCE_DIR ${PROJECT_SOURCE_DIR}/gtest
 BINARY_DIR gtest-build
 INSTALL_COMMAND  # omit installation
 )
 
 Then to link to it I need to use
 
 target_link_libraries(test
 -L${CMAKE_BINARY_DIR}/gtest-build -lgtest -lpthread
 )
 
 Is there some way to wrap that all up in a target that I can pass
 straight to target_link_libraries()?
 
 Or is my only option to create a variable that expands to those
 compiler flags?
 
 You may create an imported target, and set some properties on it:
 
 add_library(gtest STATIC IMPORTED)
 set_target_properties(gtest PROPERTIES
  IMPORTED_LOCATION  ${CMAKE_BINARY_DIR}/libgtest-build.a)
 
 You may need to set a few more properties like
 IMPORTED_LINK_INTERFACE_LIBRARIES, and you may want to use
 ${CMAKE_STATIC_LIBRARY_PREFIX}libgtest-build.${CMAKE_STATIC_LIBRARY_SUFFIX}
 instead of hardcoding lib and a.

Thanks, it works to add the following:

add_library(gtest STATIC IMPORTED)
set_target_properties(gtest PROPERTIES
IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/gtest-build/libgtest.a
IMPORTED_LINK_INTERFACE_LIBRARIES -lpthread
)

Now the only thing remaining is that all targets using this lib also
needs to find its header files.  At the moment I'm defining a variable
for it:

set(GTEST_INCDIR ${PROJECT_SOURCE_DIR}/gtest/include)

and then I need to put that into a target_include_directories(), e.g.:

target_include_directories(test_one PRIVATE
${GTEST_INCDIR}
...
)

Is it possible to put the include path in some property on the library
as well, to avoid using a separate variable for that?

If there's no standard property for it, would it be possible to use a
custom one, say INC_DIR, and then use the generator
$TARGET_PROPERTY:gtest,INC_DIR to extract it?  (I'm at all sure I've
understood generators though ;-)

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

The right to search for truth implies also a duty; one must not
conceal any part of what one has recognized to be true.
 -- Albert Einstein


pgpeWUwWcJotf.pgp
Description: PGP signature
--

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

Re: [CMake] Faking a library

2013-10-19 Thread Magnus Therning
On Sat, Oct 19, 2013 at 11:28:53AM +0400, Игорь Пашев wrote:
 2013/10/19 Magnus Therning mag...@therning.org:
  Is it possible to put the include path in some property on the library
  as well, to avoid using a separate variable for that?
 
 SET_TARGET_PROPERTIES (target PROPERTIES VARIABLE-NAME VARIABLE-VALUE)

Of course, but then how do I use it conveniently?

Would it be possible, by choosing a good property name, to simply do

target_include_directories(one_test PRIVATE
target
)

Or would I have to

get_target_property(INC_DIR target variable-name)
target_include_directories(one_test PRIVATE
${INC_DIR}
)

in which case using a property wouldn't give me very much.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

The British have the perfect temperament to be hackers--technically
skilled, slightly disrespectful of authority, and just a touch of
criminal behavior.
 -- Mary Ann Davidson, Oracle's Security Chief


pgpq1S3NF1_dR.pgp
Description: PGP signature
--

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

Re: [CMake] Faking a library

2013-10-19 Thread Magnus Therning
On Sat, Oct 19, 2013 at 08:11:52PM +0100, Nick Hutchinson wrote:
 As of 2.8.12, you can set target properties on an imported library
 to specify its include directories, compile options etc, and these
 will be automatically propagated to any other target that links to
 it via target_link_libraries(). No more tedious faffing about with
 global variables like GTEST_INCLUDE_DIRS, GTEST_LIBRARIES etc. It's
 really quite nice.
 
 Check the 2.8.12 CMake docs for target properties that start with
 INTERFACE.

That's very nice indeed :)

My complete configuration for the external library is now


externalproject_add(gtest-external
SOURCE_DIR ${PROJECT_SOURCE_DIR}/gtest
BINARY_DIR gtest-build
INSTALL_COMMAND  # omit installation
)
add_library(gtest STATIC IMPORTED)
set_target_properties(gtest PROPERTIES
IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/gtest-build/libgtest.a
IMPORTED_LINK_INTERFACE_LIBRARIES -lpthread
INTERFACE_INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/gtest/include
)


And all I need a user of the library to do is


target_link_libraries(one_test gtest)


Sweet!

Thanks for all the help.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

The early bird may get the worm, but the second mouse gets the cheese.


pgp62eZTeKd5C.pgp
Description: PGP signature
--

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

[CMake] Faking a library

2013-10-16 Thread Magnus Therning
When defining a library via add_library() it's possible to link
against it by just putting its name into target_link_libraries().  Is
there some way of wrapping up an external library in a similar way?

As a concrete example I'm playing around with gtest[1] via
externalproject_add() like this:

externalproject_add(gtest
SOURCE_DIR ${PROJECT_SOURCE_DIR}/gtest
BINARY_DIR gtest-build
INSTALL_COMMAND  # omit installation
)

Then to link to it I need to use

target_link_libraries(test
-L${CMAKE_BINARY_DIR}/gtest-build -lgtest -lpthread
)

Is there some way to wrap that all up in a target that I can pass
straight to target_link_libraries()?

Or is my only option to create a variable that expands to those
compiler flags?

/M

[1]: https://code.google.com/p/googletest/

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

As we enjoy great advantages from the inventions of others we should
be glad of an opportunity to serve others by any invention of
ours, and this we should do freely and generously.
 -- Benjamin Franklin


pgpQUmgsKGPdE.pgp
Description: PGP signature
--

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

[CMake] Generating stand-alone Visual Studio projects?

2013-10-15 Thread Magnus Therning
Hi CMake list,

A colleague and I are trying to somewhat sneak in CMake in a project
that uses Visual Studio for IDE.  This is a fairly big step to take
and we anticipate a bit of push-back, even if it clearly is a
worthwhile improvement.  One way to maybe ease the transition would be
to check in the CMake-generated solution+projects.  I took the naive
approach and just removed the CMake-generated files, the cache etc,
just keeping the VS solution+projects.  The next build I noticed that
CMake was re-run and the cache was regenerated.

Is there some way to get CMake to generate solution+projects that
don't have any tie to CMake at all, its cache or CMakeLists.txt files,
that are suitable to check into a VCS and thereby not require every
user of the code to install CMake themselves?

I am well aware of the potential problems arising from CMake not being
a round-trip tool, i.e. that changes made to the solution+projects
don't end up in the CMakeLists.txt automatically.  At this point in
time that isn't a big concern for us though.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

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


Re: [CMake] Generating stand-alone Visual Studio projects?

2013-10-15 Thread Magnus Therning
On Tue, Oct 15, 2013 at 10:56 AM, Petr Kmoch petr.km...@gmail.com wrote:
 Hi Magnus.

 I am afraid that's not really possible (safely). CMake uses absolute paths
 all over the place (by design), so all output file paths etc. are hardcoded
 in the .sln and .vc[x]proj files to the paths applicable where they were
 generated. You can experiment with the variable CMAKE_USE_RELATIVE_PATHS,
 but even its documentation warns that it's unreliable.

Well, my quick test suggests that CMAKE_USE_RELATIVE_PATHS is fairly
good, but since the documentation is worded that way there are
probably corner cases that I don't hit :)

However, one thing that I didn't notice before is that the use of the
CMake executable is deeply embedded in the solution+project
files--`cmake -E` is used very widely for obvious reasons.  Also the
path to the CMake executable is absolute and unaffected by the use of
CMAKE_USE_RELATIVE_PATHS.

I think I'll just have to give up on the idea and dig in my heels in
preparation for the inevitable discussion/complaint when introducing
CMake ;)

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

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


Re: [CMake] CMake in Vim

2013-09-28 Thread Magnus Therning
On Thu, Sep 26, 2013 at 04:39:06PM -0400, Jacky Alciné wrote:
 Hey all,
 
 I’ve been working on a Vim plug-in for Cmake. It provides a bit of
 support but it’s on the rise and I’d love to hear from the Vim +
 Cmake users about it.
 
 http://jalcine.github.io/cmake.vim/

This is excellent to hear.  At the moment I'm not working on any
project that uses CMake, but that's likely to change as soon as I can
make it happen ;-)  I'll make sure to try your plugin out properly
then.  For now here are some things that impressed me:

1. The initial quote on http://jalcine.github.io/cmake.vim/ is a
   lovely way to set the stage for the introduction of the plugin :)

2. My first thought when reading your email in here was I wonder if I
   can install it via Vundle, and reading the section on installation
   brought joy.

Sorry for not being able to actually take it for a proper spin at the
moment, but hopefully you don't find my email a complete waste of bits
:)

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

If our ideas of intellectual property are wrong, we must change them,
improve them and return them to their original purpose. When
intellectual property rules diminish the supply of new ideas, they
steal from all of us.
 -- Andrew Brown, November 19, 2005, The Guardian


pgpbeiJR4DvWl.pgp
Description: PGP signature
--

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

[CMake] -rdynamic causing problems for compiler checks

2013-03-19 Thread Magnus Therning
I'm using CMake (2.8.10.2) in an embedded project, which so far has
worked great.  However, now I'm trying out a newer version of the
compiler and I'm running into issues with '-rdynamic' when CMake
checks the compiler.  The issue I see is this:


-- Check for working C compiler:
/opt/rt-tools/compilers/arm-eabi/bin/arm-eabi-gcc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61
(message):
  The C compiler /opt/rt-tools/compilers/arm-eabi/bin/arm-eabi-gcc is not
  able to compile a simple test program.

  It fails with the following output:

   Change Dir: 
/home/semth/HBwork/floydi/floyd-build/floyd-ninja/CMakeFiles/CMakeTmp



  Run Build Command:/usr/bin/make cmTryCompileExec1091315603/fast

  /usr/bin/make -f CMakeFiles/cmTryCompileExec1091315603.dir/build.make
  CMakeFiles/cmTryCompileExec1091315603.dir/build

  make[1]: Entering directory
  `/home/semth/HBwork/floydi/floyd-build/floyd-ninja/CMakeFiles/CMakeTmp'

  /usr/bin/cmake -E cmake_progress_report
  
/home/semth/HBwork/floydi/floyd-build/floyd-ninja/CMakeFiles/CMakeTmp/CMakeFiles
  1

  Building C object
  CMakeFiles/cmTryCompileExec1091315603.dir/testCCompiler.c.o

  /opt/rt-tools/compilers/arm-eabi/bin/arm-eabi-gcc -o
  CMakeFiles/cmTryCompileExec1091315603.dir/testCCompiler.c.o -c
  
/home/semth/HBwork/floydi/floyd-build/floyd-ninja/CMakeFiles/CMakeTmp/testCCompiler.c


  Linking C executable cmTryCompileExec1091315603

  /usr/bin/cmake -E cmake_link_script
  CMakeFiles/cmTryCompileExec1091315603.dir/link.txt --verbose=1

  /opt/rt-tools/compilers/arm-eabi/bin/arm-eabi-gcc
  CMakeFiles/cmTryCompileExec1091315603.dir/testCCompiler.c.o -o
  cmTryCompileExec1091315603 -rdynamic

  arm-eabi-gcc: error: unrecognized option '-rdynamic'


I have the following lines in my tool chain file:


set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS  )
set( CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS  )


which does remove the '-rdynamic' argument when compiling the
*project*, however they don't seem remove the flag on the *compiler
check*.  I found an old issue that seems related,
http://www.cmake.org/Bug/view.php?id=9985, it's been closed for years.

Is there some way to remove the flag on compiler checks, or is my only
option to disable compiler checks alltogether?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] -rdynamic causing problems for compiler checks

2013-03-19 Thread Magnus Therning
Oups, this was due to my own ignorance.  I really shouldn't set
CMAKE_SYSTEM_NAME to Linux when cross-compiling for an ARM system
with an RTOS :)  Sorry for the noise.

/M

On Tue, Mar 19, 2013 at 10:44 AM, Magnus Therning mag...@therning.org wrote:
 I'm using CMake (2.8.10.2) in an embedded project, which so far has
 worked great.  However, now I'm trying out a newer version of the
 compiler and I'm running into issues with '-rdynamic' when CMake
 checks the compiler.  The issue I see is this:

 
 -- Check for working C compiler:
 /opt/rt-tools/compilers/arm-eabi/bin/arm-eabi-gcc -- broken
 CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61
 (message):
   The C compiler /opt/rt-tools/compilers/arm-eabi/bin/arm-eabi-gcc is not
   able to compile a simple test program.

   It fails with the following output:

Change Dir: 
 /home/semth/HBwork/floydi/floyd-build/floyd-ninja/CMakeFiles/CMakeTmp



   Run Build Command:/usr/bin/make cmTryCompileExec1091315603/fast

   /usr/bin/make -f CMakeFiles/cmTryCompileExec1091315603.dir/build.make
   CMakeFiles/cmTryCompileExec1091315603.dir/build

   make[1]: Entering directory
   `/home/semth/HBwork/floydi/floyd-build/floyd-ninja/CMakeFiles/CMakeTmp'

   /usr/bin/cmake -E cmake_progress_report
   
 /home/semth/HBwork/floydi/floyd-build/floyd-ninja/CMakeFiles/CMakeTmp/CMakeFiles
   1

   Building C object
   CMakeFiles/cmTryCompileExec1091315603.dir/testCCompiler.c.o

   /opt/rt-tools/compilers/arm-eabi/bin/arm-eabi-gcc -o
   CMakeFiles/cmTryCompileExec1091315603.dir/testCCompiler.c.o -c
   
 /home/semth/HBwork/floydi/floyd-build/floyd-ninja/CMakeFiles/CMakeTmp/testCCompiler.c


   Linking C executable cmTryCompileExec1091315603

   /usr/bin/cmake -E cmake_link_script
   CMakeFiles/cmTryCompileExec1091315603.dir/link.txt --verbose=1

   /opt/rt-tools/compilers/arm-eabi/bin/arm-eabi-gcc
   CMakeFiles/cmTryCompileExec1091315603.dir/testCCompiler.c.o -o
   cmTryCompileExec1091315603 -rdynamic

   arm-eabi-gcc: error: unrecognized option '-rdynamic'
 

 I have the following lines in my tool chain file:

 
 set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS  )
 set( CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS  )
 

 which does remove the '-rdynamic' argument when compiling the
 *project*, however they don't seem remove the flag on the *compiler
 check*.  I found an old issue that seems related,
 http://www.cmake.org/Bug/view.php?id=9985, it's been closed for years.

 Is there some way to remove the flag on compiler checks, or is my only
 option to disable compiler checks alltogether?

 /M

 --
 Magnus Therning  OpenPGP: 0xAB4DFBA4
 email: mag...@therning.org   jabber: mag...@therning.org
 twitter: magthe   http://therning.org/magnus



-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] CMake+Eclipse: how to get header files with non-standard suffix into the headers folders?

2013-03-13 Thread Magnus Therning
On Mon, Mar 11, 2013 at 8:49 PM, Alexander Neundorf
a.neundorf-w...@gmx.net wrote:
 On Monday 11 March 2013, Magnus Therning wrote:
 In the project I work on we have tools that generate quite a few
 header files, but they are all generated with names matching *.inc.
 I've added them all to the list of sources for the target, but the
 generated Eclipse project doesn't list these files among the headers.
 Is there a way to tell CMAKE that *.inc files are headers and thus
 should go into the headers folders in Eclipse projects?

 Please enter a feature request on http://public.kitware.com/Bug/, I'll have a
 look at it.

I've entered it as 14008 : http://public.kitware.com/Bug/view.php?id=14008

Hopefully I've included enough information so you can have a look at it.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] CMake+Eclipse: how to get header files with non-standard suffix into the headers folders?

2013-03-11 Thread Magnus Therning
In the project I work on we have tools that generate quite a few
header files, but they are all generated with names matching *.inc.
I've added them all to the list of sources for the target, but the
generated Eclipse project doesn't list these files among the headers.
Is there a way to tell CMAKE that *.inc files are headers and thus
should go into the headers folders in Eclipse projects?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Eclipse/CMake projects show same file multiple times

2013-03-08 Thread Magnus Therning
On Thu, Mar 07, 2013 at 10:15:44PM +0100, Alexander Neundorf wrote:
 On Thursday 07 March 2013, Campbell Barton wrote:
  With default Eclipse project (version 2.8.10.2), Eclipse CDT4 - Unix
  Makefiles, I get the same file showing multiple times when using
  Open-Resources.
  
  It also shows object files in the listing (.o) which is fairly
  annoying and makes Open-Resources not that useful.
  
  Example screenshot:
  http://www.graphicall.org/ftp/ideasman42/eclipse_cmake_project.png
  
  Is this a known problem?, Should I report a bug?
 
 Set the cmake variable CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES to FALSE 
 (since 
 2.8.10 I think, it's in the cache) to FALSE, and see whether this is better 
 for you.
 
 Also, please try 2.8.11, for which RCs will be out really soon now. This has 
 an additional change which has to do with this.

Ah, I'll definitely have to try that trick.

Another, but related question, when using the Eclipse+Ninja generator
I end up with an awful lot of Ninja-related files in the top level of
the Eclipse project.  Is there some way to avoid that?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Most software today is very much like an Egyptian pyramid with
millions of bricks piled on top of each other, with no structural
integrity, but just done by brute force and thousands of slaves.
 -- Alan Kay


pgp6RKYfaGS1q.pgp
Description: PGP signature
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Eclipse/CMake projects show same file multiple times

2013-03-07 Thread Magnus Therning
On Fri, Mar 08, 2013 at 12:32:52AM +1100, Campbell Barton wrote:
 With default Eclipse project (version 2.8.10.2), Eclipse CDT4 - Unix
 Makefiles, I get the same file showing multiple times when using
 Open-Resources.
 
 It also shows object files in the listing (.o) which is fairly
 annoying and makes Open-Resources not that useful.
 
 Example screenshot:
 http://www.graphicall.org/ftp/ideasman42/eclipse_cmake_project.png
 
 Is this a known problem?, Should I report a bug?

+1

Also, I've noted that while source files (in my case *.c and *.cpp)
appear under virtual source folders, there are no header files under
the virtual header folders.  (I can provide screenshots tomorrow, if
needed).  Adding headers to the sources of apps/libraries has no
effect.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
 -- Alan Kay


pgpru1tLnuxge.pgp
Description: PGP signature
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Per-target include dirs that work in both 2.8.7 and 2.8.10.2?

2013-03-02 Thread Magnus Therning
On Thu, Feb 28, 2013 at 12:45:47PM -0500, Bill Hoffman wrote:
 On 2/28/2013 12:29 PM, Alexander Neundorf wrote:
 Sorry, no, this is a new feature since cmake 2.8.8.
 
 Alex
 Only way to do it before was to make sure each target is in its own
 directory and then manipulate the includes from there.

Good... well, not that good, but at least I haven't missed anything
when looking for the answer myself ;)

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Per-target include dirs that work in both 2.8.7 and 2.8.10.2?

2013-03-02 Thread Magnus Therning
On Thu, Feb 28, 2013 at 03:19:48PM -0500, Jean-Christophe Fillion-Robin wrote:
 Hi Magnus,
 
 As already mentioned, the target property INCLUDE_DIRECTORIES has been
 introduced in CMake 2.8.8. The following page is useful to find out such
 things. See
 http://www.cmake.org/Wiki/CMake_Version_Compatibility_Matrix/Properties#Properties_on_Targets
 
 To get around it, as mentioned by Bill, you could probably create on folder
 per target and call include_directories() in each folder.
 
 An other option could be to create a wrapper around the add_target
 command that would create a directory, write a CMakeLists and then
 call add_subdirectory(/path/to/project-build/target target).

I went for the much easier solution: convince my colleague that he
*really* needs a newer version of cmake on his system... the amount of
extra goodness by far outweighs the trouble of upgrading ;)

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Per-target include dirs that work in both 2.8.7 and 2.8.10.2?

2013-02-28 Thread Magnus Therning
The other day I was putting together some cmake files and made them
work on my system, where I have version 2.8.10.2 installed.  After
giving my work to a colleague he reported that it didn't work.  It
came down to him using version 2.8.7 (comes with his Linux distro) and
my use of


set_property( TARGET app PROPERTY INCLUDE_DIRECTORIES

)


In the folder in question there is source for several different
targets, so I'd really like to use per-target include dirs (i.e.
include_directories would not be a good match).  Is there a mechanism
for (easily) getting per-target include dirs that work in both these
versions?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] CMake OCaml

2010-08-25 Thread Magnus Therning
A while ago I started looking at using CMake to build OCaml projects.  As part
of that I put together some useful (but maybe not very beautiful) macros.
They are available on github[1].

I've come to the conclusion that while CMake is a rather good build tool, it
isn't very well designed to add full support for slightly esoteric languages
and tool chains like OCaml.

So I've decided that I won't spend more time on OCaml for CMake.  Feel free to
take the code and do what you want with it :-)

/M

[1] http://github.com/magthe/cmake-ocaml
-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] target name tweak

2010-08-15 Thread Magnus Therning
On 15/08/10 22:11, SK wrote:
 When using the D language compiler 'dmd' on windows, I'm stuck with a
 linker that gets confused with object file names like foo.c.obj.  The
 linker can only handle a single dot in the object file name, as in
 foo.o
 
 How can I set target names to just be the base name without the source
 extension?  I need to do this in the language support module, e.g.
 Modules\Platform\Windows-dmd.cmake, so that users don't need to hack
 this in their own CMakeLists.txt files.

Instead of adding '.obj' to the full filename, first extract the
filename-extension (see get_filename_component()) and then add '.o' to that.

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org   Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe



signature.asc
Description: OpenPGP digital signature
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Complex command

2010-08-10 Thread Magnus Therning
On Fri, Aug 6, 2010 at 20:18, Ryan Pavlik rpav...@iastate.edu wrote:
  On 8/6/10 1:12 PM, Magnus Therning wrote:

 I was trying to put something like this into a CMake file:

 add_custom_command( ...
     COMMAND ...
     COMMAND ([[ -f foo ]] || ln -sf foo bar); true
     )

 But CMake won't have it.  Skipping the sub-shell is all right with CMake:

 add_custom_command( ...
     COMMAND ...
     COMMAND [[ -f foo ]] || ln -sf foo bar
     )

 But then make doesn't like it if the file doesn't exist, it exits with an
 error.

 I put the command in an external shell script instead, but would rather
 not do
 that.

 Any suggestions?

 /M

 You could create/dynamically at configure time write out a cmake file that
 does something to the effect of:
 if(EXISTS foo)
    execute_process(COMMAND ${CMAKE_COMMAND}) -E create_symlink oldfilename
 newfilename)
 endif()

 then make your custom command run cmake in script mode on that file.  This
 will let you be cross-platform in a good way.

Thanks, that does the trick.

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Complex command

2010-08-06 Thread Magnus Therning
I was trying to put something like this into a CMake file:

add_custom_command( ...
COMMAND ...
COMMAND ([[ -f foo ]] || ln -sf foo bar); true
)

But CMake won't have it.  Skipping the sub-shell is all right with CMake:

add_custom_command( ...
COMMAND ...
COMMAND [[ -f foo ]] || ln -sf foo bar
)

But then make doesn't like it if the file doesn't exist, it exits with an
error.

I put the command in an external shell script instead, but would rather
not do
that.

Any suggestions?

/M



signature.asc
Description: OpenPGP digital signature
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Building source RPMs?

2010-08-05 Thread Magnus Therning
I'm currently using CPack to build binary RPMs, is there a way to also
generate a source RPM?

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Building source RPMs?

2010-08-05 Thread Magnus Therning
On Thu, Aug 5, 2010 at 10:39, Eric Noulard eric.noul...@gmail.com wrote:
 2010/8/5 Magnus Therning mag...@therning.org:
 I'm currently using CPack to build binary RPMs, is there a way to also
 generate a source RPM?

 Not yet...with CPackRPM.

 Building  a source RPM with CMake/CPack is not as easy as building a
 binary RPM. Because currently the spec file used to build a binary RPM
 is a short-cutted one:
   - the %prep step is a simple move of directory
   - the %build is void (because CMake BUILDTOOL should have already done
     the build
   - the %install is a simple move too (because CPack did the install
 on it's own)

 This is due to the fact that when you call CPack,
   - CMake has been called
   - The software has been built
   - CPack will call install for you BEFORE calling the CPackRPM generator
   in the end CPackRPM just have to package the already built and
 installed file.

 In a source RPM you should specify the steps (%prep, %build, %install)
 what CMake/CPack usually do.  So basically the RPM spec file to use
 for building a source RPM won't be the same as the one used to build
 the current binary RPM.

 So implementing a Source RPM generator is doable,
 and in fact it was done in the UseRPMTools.cmake macro
 http://www.cmake.org/Wiki/CMakeUserUseRPMTools
 which is the ancestor of CPackRPM.

 The drawback of the old UseRPMTools is that even for a binary RPM
 it will redo all the steps including calling CMake etc...

 Why do you need to build a Source RPM with CPack ?

To match the behaviour of the current build system :-)
I think that using the VCS archive feature will be as good a replacement
though.

 What is your usage pattern?

We ship most of our sources as source RPMs since most of our changes are added
patches to upstream (CentOS) RPMs.

It is just nice to also ship the source of our own code as RPMs rather than as
tar-ball.  However, I don't see a big problem with simply dropping use of
CPack and writing the SPEC files manually.  It would just be a nice-to-have is
all.

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Building source RPMs?

2010-08-05 Thread Magnus Therning
On 05/08/10 20:25, Alexander Neundorf wrote:
 On Thursday 05 August 2010, Magnus Therning wrote:
 On Thu, Aug 5, 2010 at 10:39, Eric Noulard eric.noul...@gmail.com
 wrote:
 ...
 What is your usage pattern?

 We ship most of our sources as source RPMs since most of our changes are
 added patches to upstream (CentOS) RPMs.

 It is just nice to also ship the source of our own code as RPMs rather
 than as tar-ball.  However, I don't see a big problem with simply
 dropping use of CPack and writing the SPEC files manually.  It would
 just be a nice-to-have is all.
 
 Somehow I don't really understand how a source RPM or source deb
 generator would make sense for CPack.  E.g. a source deb is the plain
 source package, plus an optional patch, plus a file which describes how
 to build it.  IMO the patch would be always non-existent if generated
 with CPack (since this generates the package directly from the original
 source tree), so the only thing left would be to generate the spec file.
 I guess for a source RPM it's similar ?

You misunderstood me.  Our stuff consists of two types of RPMs:

 1. Source taken from upstream distro (CentOS), with patches added.
We use the source RPM upstream provides, with minimal changes to
SPEC files to get our patches into the resulting binary RPM.  To
comply with licenses we ship source RPMs that include our patches.
 2. In-house developed code.  The current build system builds binary
RPMs, since that's what the installer is good at handling.  It
also simplifies distribution of updates.  The build system also
spits out source RPMs, since some things require releasing of
source.  This is what we're looking at building with CMake/CPack.
Hence my question.

Hopefully this makes it clearer.

/M



signature.asc
Description: OpenPGP digital signature
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] CPack (RPM) and install()

2010-06-23 Thread Magnus Therning
On Wed, Jun 23, 2010 at 15:41, Eric Noulard eric.noul...@gmail.com wrote:
 2010/6/23 Magnus Therning mag...@therning.org:
[...]
 - The variable CMAKE_INSTALL_PREFIX is not used at all during RPM
 building.  CMAKE_INSTALL_PREFIX is /usr/local, but files get put into
 /usr in the RPM.  Is this a bug?

 It should be using it.

Here's an example of what I mean:

  bash-3.2# cmake ..
  -- Found OCAML: 3.11.0
  -- prefix: /usr/local
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /myrepos/ocaml-libs.hg/_build
  bash-3.2# make DESTDIR=_install install  /dev/null
  bash-3.2# tree _install/
  _install/
  `-- usr
  `-- local
  `-- lib
  `-- ocaml
  `-- ocamltest
  |-- META
  |-- ocamltest.a
  |-- ocamltest.cma
  |-- ocamltest.cmi
  |-- ocamltest.cmxa
  |-- ocamltest.ml
  `-- ocamltest.mli

  5 directories, 7 files
  bash-3.2# make package  /dev/null
  bash-3.2# rpm -ql -p ocaml-libs-0.0.0-Linux.rpm
  /usr
  /usr/lib
  /usr/lib/ocaml
  /usr/lib/ocaml/ocamltest
  /usr/lib/ocaml/ocamltest/META
  /usr/lib/ocaml/ocamltest/ocamltest.a
  /usr/lib/ocaml/ocamltest/ocamltest.cma
  /usr/lib/ocaml/ocamltest/ocamltest.cmi
  /usr/lib/ocaml/ocamltest/ocamltest.cmxa
  /usr/lib/ocaml/ocamltest/ocamltest.ml
  /usr/lib/ocaml/ocamltest/ocamltest.mli

 Which version of CMake/CPack are you using.

 Could you try:
 cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM

 and send me the output?

 More infos on how to control CPackRPM with CPACK_RPM_xxx vars:
 http://www.itk.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
 or
 cmake --help-module CPackRPM

I'll take a look at this since I need to fix what's included in the source RPM
next :-)

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Building in stages.

2010-06-22 Thread Magnus Therning
On Mon, Jun 21, 2010 at 17:46, Aeschbacher, Fabrice
fabrice.aeschbac...@siemens.com wrote:
 I would try following in foo/CmakeLists.txt:

   add_custom_command(TARGET foo
      POST_BUILD
      COMMAND touch bar/CMakeLists.txt
   )

 This will force CMake to re-build the makefiles for 'bar' (because its
 CMakeLists.txt has been modified)

 And of course, add_dependencies(bar foo)

It might, but it still feels like a rather strange way to go about it.

I'll make yet another attempt to explain the situation, hopefully better so
that it becomes more clear what the problem is.

There are three tools involved:

  camlp4 - an extensible pre-processor, it makes it possible to modify OCaml
   and even add syntax
  ocamldep - a tool that inspects a source file and tells you what it depends
 on, it can be told to use a preprocessor through its -pp argument
  ocamlc - the OCaml compiler, it can be told to use a preprocessor through
   its -pp argument

Somewhat simplified the project I'm converting to use CMake has two parts:

  foo - an extension to camlp4
  bar - an OCaml module, wich uses the syntax extensions implemented in foo

So if I understand you, these would roughly be the steps I need to take:

1. Call 'cmake' (manual)
This must skip dependency generation for bar; foo isn't built yet and
hence ocamldep will not be able to parse the source for bar.
2. Call 'make' (manual)
Builds foo, and as a last thing touch the CMakeLists.txt for bar.

Now you're saying that because of the post-build step in 2 the following will
happen automatically, right?

3. Call to 'cmake' (automatic)
Now foo has been built so the correct dependencies for bar can be
determined.  (I have yet to find out exactly *how* I can determine that
foo already is built, but that sounds like it shouldn't be too difficult.)

4. Call to 'make' (automatic)
Now the Makefile for bar contains the correct dependency information and
the build can continue.

Have I understood you correctly?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Building in stages.

2010-06-22 Thread Magnus Therning
On Tue, Jun 22, 2010 at 07:48, Michael Wild them...@gmail.com wrote:
[...]
 Ahh, now I understand. You need foo already at cmake-time, not at make-time. 
 Ideally you'd want to run ocamldep at make-time to determine the file-level 
 dependencies, like cmake does for C/C++/Fortran/Java. However, I don't think 
 there's a way to do so currently. IMHO this would be a good feature-request 
 in the bug tracker.

Yes, indeed :-)  And how disappointing that CMake doesn't support it already :-(

I created http://public.kitware.com/Bug/view.php?id=10862
Please add clarifying words as needed :-)

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Building in stages.

2010-06-21 Thread Magnus Therning
I'm looking for some suggestions on how to tackle a problem with staged
builds.

In trying to convert a project which uses omake to build OCaml files I've
stumbled on the issue that building one sub-part (bar) of the project needs
the result of another sub-part (foo).  The twist is that foo is required
already at the dependency-discovery stage of bar[1].  Is there some clever way
of working around this?

One obvious solution would be to simply skip automatic generation of
dependencies for bar, but that feels a little naughty.  It feels about as
naughty as how the previous build system just worked by ordering[2].

Hopefully there's some better way of achieving this, any suggestions?

/M

[1] For those initiated in OCaml and its tools stack the former sub-part
builds a custom filter for camlp4 which is then used in the latter sub-part.
[2] omake is very similar to make and in this case the build of foo just
happened before bar, and there was no attempt at automatic generation of
dependencies at all.
-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Building in stages.

2010-06-21 Thread Magnus Therning
On Mon, Jun 21, 2010 at 16:10, Michael Wild them...@gmail.com wrote:

 I'm looking for some suggestions on how to tackle a problem with staged
 builds.

 In trying to convert a project which uses omake to build OCaml files I've
 stumbled on the issue that building one sub-part (bar) of the project needs
 the result of another sub-part (foo).  The twist is that foo is required
 already at the dependency-discovery stage of bar[1].  Is there some clever 
 way
 of working around this?

 One obvious solution would be to simply skip automatic generation of
 dependencies for bar, but that feels a little naughty.  It feels about as
 naughty as how the previous build system just worked by ordering[2].

 Hopefully there's some better way of achieving this, any suggestions?

 /M

 [1] For those initiated in OCaml and its tools stack the former sub-part
 builds a custom filter for camlp4 which is then used in the latter sub-part.
 [2] omake is very similar to make and in this case the build of foo just
 happened before bar, and there was no attempt at automatic generation of
 dependencies at all.

 Well, if you need foo to be built before bar, just use add_dependencies(bar 
 foo). File-level dependency scanning happens just before bar is built, so if 
 I understand your question correctly, you should be fine now...

No, I need foo to be built before bar is inspected to gather its
dependencies.  And dependencies for both foo and bar are gathered when
calling `cmake` to generate the Makefiles.  This is how my OCaml
support works at the moment.  If you have suggestions for how to move
the dependency generation to compile time (i.e. when calling `make`)
then I'd be very glad to hear it.  Or even better, be pointed to an
example of how to achieve that.

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Unit tests, but not CTest

2010-05-16 Thread Magnus Therning
On 14/05/10 22:28, Michael Hertling wrote:
 On 05/14/2010 08:24 AM, Magnus Therning wrote:
[...]
 Thanks for this analysis, it makes the problem a lot clearer to me.  One
 thing it doesn't clarify is how ADD_CUSTOM_COMMAND( TARGET ... POST_BUILD )
 could *ever* be useful. [...]
 
 ADD_CUSTOM_COMMAND(TARGET ...) enhances the commands associated with the
 named target, i.e. you can hook into that target's build process:
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
 
 PROJECT(CUSTOM_COMMAND_DEMO C)
 
 FILE(WRITE main.c void main(){})
 ADD_EXECUTABLE(exe main.c)
 
 ADD_CUSTOM_COMMAND(TARGET exe PRE_BUILD COMMAND echo Pre build)
 ADD_CUSTOM_COMMAND(TARGET exe POST_BUILD COMMAND echo Post build)
 
 After cmaking, look at the end of CMakeFiles/exe.dir/build.make:
 
 [...]
 exe: CMakeFiles/exe.dir/main.c.o
 exe: CMakeFiles/exe.dir/build.make
 exe: CMakeFiles/exe.dir/link.txt
 @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red
 --bold Linking C executable exe
 echo Pre\ build
 $(CMAKE_COMMAND) -E cmake_link_script
 CMakeFiles/exe.dir/link.txt --verbose=$(VERBOSE)
 echo Post\ build
 [...]
 
 Thus, ADD_CUSTOM_COMMAND(TARGET ...) doesn't modify the dependencies of the
 named target but the associated commands. So, it provides a general
 possibility to have arbitrary commands run when a target is (re)built.

Ah, sorry, I managed to use the wrong word, useful when I really should have
written used.  I can see its usefulness, indeed I *wanted* to use it myself.
However, earlier in this thread it became apparent that
add_custom_command( OUTPUT foo ... ) can't be used together with
add_custom_command( TARGET foo POST_BUILD ... ); the latter would *never* be
executed.  It was also apparent that add_custom_target( foo ... ) can't be
used with add_custom_command( TARGET foo POST_BUILD ...); the latter would
then *always* be executed.

Now you say that if I use add_executable( foo ... ) then I can use
add_custom_command( TARGET foo POST_BUILD ... ).  So, what does
add_executable( ... ) do?

I was under the impression that add_executable( ... ) deep down wasn't much
more than a wrapper around add_custom_command( OUTPUT ... ) (since that is the
only way I know to get anything built through the CMake scripts).  However now
you've made me think that add_executable( ... ) is a bit magical.  If that's
the case, then how does one go about adding full support for a language (i.e.
so that add_executable( ... ) can be used for that language) using nothing but
CMake scripts?

 [...] I'm still to see an example of any buildable target that
 such a post-build command can be connected to and only triggered on 
 (re)build.
 
 Imagine your add_ocaml_executable() using ADD_EXECUTABLE() instead of
 ADD_CUSTOM_COMMAND(OUTPUT ...); in this case, you would have a, say,
 fully-fledged CMake target which additional commands can be attached to by
 ADD_CUSTOM_COMMAND(TARGET ...), and indeed, that is a suitable place for
 your automated unit testing. Obviously, CMake's file-level targets defined
 by ADD_CUSTOM_COMMAND(OUTPUT ...) are not sufficient for this purpose
 although they appear as usual Make targets if others depend on them, but so,
 you've to specify the desired commands right in the
 ADD_CUSTOM_COMMAND(OUTPUT ...). Perhaps, this would be worth a feature
 request.

This seems to support my line of reasoning above, i.e. that adding full
language support for new language (i.e. making it possible to use
add_executable( ... ) on OCaml sources) isn't possible using CMake scripts
alone.  Is that correct?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe



signature.asc
Description: OpenPGP digital signature
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Unit tests, but not CTest

2010-05-13 Thread Magnus Therning
On Thu, May 13, 2010 at 07:46, Michael Hertling mhertl...@online.de wrote:
 On 05/13/2010 07:36 AM, Magnus Therning wrote:
 On 13/05/10 02:31, Michael Hertling wrote:
 On 05/11/2010 10:51 AM, Magnus Therning wrote:
 I'm still having problems with this.

 I put together this:

     project( test-post-build NONE )
     cmake_minimum_required( VERSION 2.8 )

     set( output ${CMAKE_CURRENT_BINARY_DIR}/foo )
     add_custom_command( OUTPUT ${output}
         COMMAND touch ${output}
         COMMENT Touching foo
         )
     add_custom_target( foo.build ALL DEPENDS ${output} )

     add_custom_command( TARGET ${output}
         POST_BUILD
         COMMAND echo POST_BUILD ${output}
         )

     add_custom_command( TARGET foo.build
         POST_BUILD
         COMMAND echo POST_BUILD foo.build
         )

 Based on your description above I expected this behaviour:

     % cmake ..
     -- Configuring done
     -- Generating done
     -- Build files have been written to:
 /home/magnus/Play/test/cmake/post_build/_build
     % make
     Scanning dependencies of target foo.build
     [  0%] Touching foo
     POST_BUILD /home/magnus/Play/test/cmake/post_build/_build/foo
     POST_BUILD foo.build
     [100%] Built target foo.build
     % make
     POST_BUILD foo.build
     [100%] Built target foo.build

 However, that's not the case.  I only ever see the 'POST_BUILD foo.build'
 printed. [...]

 AFAIK, this is because your add_custom_command(TARGET ${output} ...)
 is not associated with an actual target but with just a file whereas
 add_custom_command(TARGET foo.build ...) actually refers to a target
 foo.build defined by ADD_CUSTOM_TARGET(). Indeed, you may issue any
 ADD_CUSTOM_COMMAND(TARGET ...) for undefined targets without causing
 an error, but their commands will never be executed, of course.

 [...] So, what target can I use to get the desired behaviour of the
 POST_BUILD only being run after an actual build?

 Just use a target - but really a target - after whose rebuild you like
 to have your post-build custom commands being run.

 Hope this helps.

 I'm sorry, but it doesn't :-(  I have two POST_BUILD commands above, one
 attached to the creation of a file and one to a target.  The former I thought
 was attached to the creation of a file (the OUTPUT of a command) the latter 
 to
 a custom target (which depends on the OUTPUT of the former).  The former is
 *never* run, the latter is *always* run.  The explanations in this thread so
 far has explained why CMake behaves this way, but how do I make the creation
 of the file into a target - but really a target so I can attach the
 POST_BUILD command to it?

 Would you mind correcting my CMake script from above as an example of how it
 can be done?

 I have the following:

      project( test-post-build NONE )
      cmake_minimum_required( VERSION 2.8 )

      set( output ${CMAKE_CURRENT_BINARY_DIR}/foo )
      add_custom_command( OUTPUT ${output}
          COMMAND touch ${output}
          COMMENT Touching foo
          )

 I now want the text POST_BUILD echoed to stdout iff the command to create
 ${output} is run.  (With the explanations I've gotten in this thread so far I
 don't even see how that can be done.)

 OK, I see. Perhaps, the solution for your concern is pretty easy: Try

     add_custom_command( OUTPUT ${output}
         COMMAND touch ${output}
         COMMAND echo POST_BUILD ${output}
         COMMENT Touching foo
         )

 and forget the add_custom_command( TARGET ${output} ... ). This just
 means that the latter's command is directly tied to the generation of
 ${output}, and so, you even get exactly what you expected at first:

 % cmake ..
 -- Configuring done
 -- Generating done
 -- Build files have been written to: [...]
 % make
 Scanning dependencies of target foo.build
 [  0%] Touching foo
 POST_BUILD [...]/foo
 POST_BUILD foo.build
 [100%] Built target foo.build
 % make
 POST_BUILD foo.build
 [100%] Built target foo.build

 In other words, there would be no need to attach additional commands to
 ADD_CUSTOM_COMMAND(OUTPUT ...) via ADD_CUSTOM_COMMAND(TARGET ...), but
 one can specify them directly within the former, and for more complex
 operations, one can use ADD_CUSTOM_COMMAND()'s DEPENDS option to
 trigger arbitrary targets when the OUTPUT is regenerated.

 Is this the desired behaviour?

It's not ideal.

I'm writing some CMake scripts to ease the use of OCaml with CMake.  There are
basically two macros at this point:

• add_ocaml_library()
• add_ocaml_executable()

Both of them can somewhat simplistically be thought of as just wrappers around
add_custom_command().  In some cases the OCaml executable is a unit test,
which means I'd like the executable to be run after being built.  Ideally I'd
like to write macros that would be used this way:

add_ocaml_executable( myexe ... )
add_ocaml_unittest( myexe )

However, if I understand you correctly that wouldn't be possible.  Instead
I'll have to either create a specific

Re: [CMake] process file contents

2010-05-12 Thread Magnus Therning
On 12/05/10 19:07, James C. Sutherland wrote:
 
 On May 12, 2010, at 11:43 AM, James C. Sutherland wrote:
 
 I would like to execute a command like:
 getrates -n  myFileName

 I am trying to add this so it is processed after the target getrates
 is built

 set( infile ${CMAKE_CURRENT_BINARY_DIR}/myFileName )
 add_custom_command( TARGET getrates
   POST_BUILD
   COMMAND ${CMAKE_CURRENT_BINARY_DIR}/getrates  -n  ${infile}
   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
   VERBATIM
   )


 This does not seem to work, however.  CMake doesn't handle the 
 properly.  Any ideas about how to stream the contents of a file?

 Thanks,

 James
 
 Got it.  It looks like removing the  from the arguments does the job, i.e.
 
 add_custom_command( TARGET getrates
   POST_BUILD
   COMMAND ${CMAKE_CURRENT_BINARY_DIR}/getrates -n  ${infile}
   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
   VERBATIM
   )

Yes, I learned this the hard way too.  Basically it seems that an argument in
ticks () will be passed in as a single argument (handy when arguments
contain spaces).  That means that the equivalent shell command line was

% getrates  -n  infile

i.e. a single argument to the `getrates` command.

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe



signature.asc
Description: OpenPGP digital signature
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Unit tests, but not CTest

2010-05-12 Thread Magnus Therning
On 13/05/10 02:31, Michael Hertling wrote:
 On 05/11/2010 10:51 AM, Magnus Therning wrote:
 I'm still having problems with this.

 I put together this:

 project( test-post-build NONE )
 cmake_minimum_required( VERSION 2.8 )

 set( output ${CMAKE_CURRENT_BINARY_DIR}/foo )
 add_custom_command( OUTPUT ${output}
 COMMAND touch ${output}
 COMMENT Touching foo
 )
 add_custom_target( foo.build ALL DEPENDS ${output} )

 add_custom_command( TARGET ${output}
 POST_BUILD
 COMMAND echo POST_BUILD ${output}
 )

 add_custom_command( TARGET foo.build
 POST_BUILD
 COMMAND echo POST_BUILD foo.build
 )

 Based on your description above I expected this behaviour:

 % cmake ..
 -- Configuring done
 -- Generating done
 -- Build files have been written to:
 /home/magnus/Play/test/cmake/post_build/_build
 % make
 Scanning dependencies of target foo.build
 [  0%] Touching foo
 POST_BUILD /home/magnus/Play/test/cmake/post_build/_build/foo
 POST_BUILD foo.build
 [100%] Built target foo.build
 % make
 POST_BUILD foo.build
 [100%] Built target foo.build

 However, that's not the case.  I only ever see the 'POST_BUILD foo.build'
 printed. [...]
 
 AFAIK, this is because your add_custom_command(TARGET ${output} ...)
 is not associated with an actual target but with just a file whereas
 add_custom_command(TARGET foo.build ...) actually refers to a target
 foo.build defined by ADD_CUSTOM_TARGET(). Indeed, you may issue any
 ADD_CUSTOM_COMMAND(TARGET ...) for undefined targets without causing
 an error, but their commands will never be executed, of course.
 
 [...] So, what target can I use to get the desired behaviour of the
 POST_BUILD only being run after an actual build?
 
 Just use a target - but really a target - after whose rebuild you like
 to have your post-build custom commands being run.
 
 Hope this helps.

I'm sorry, but it doesn't :-(  I have two POST_BUILD commands above, one
attached to the creation of a file and one to a target.  The former I thought
was attached to the creation of a file (the OUTPUT of a command) the latter to
a custom target (which depends on the OUTPUT of the former).  The former is
*never* run, the latter is *always* run.  The explanations in this thread so
far has explained why CMake behaves this way, but how do I make the creation
of the file into a target - but really a target so I can attach the
POST_BUILD command to it?

Would you mind correcting my CMake script from above as an example of how it
can be done?

I have the following:

 project( test-post-build NONE )
 cmake_minimum_required( VERSION 2.8 )

 set( output ${CMAKE_CURRENT_BINARY_DIR}/foo )
 add_custom_command( OUTPUT ${output}
 COMMAND touch ${output}
 COMMENT Touching foo
 )

I now want the text POST_BUILD echoed to stdout iff the command to create
${output} is run.  (With the explanations I've gotten in this thread so far I
don't even see how that can be done.)

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe



signature.asc
Description: OpenPGP digital signature
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Unit tests, but not CTest

2010-05-11 Thread Magnus Therning
On Mon, May 10, 2010 at 17:28, Tyler Roscoe ty...@cryptio.net wrote:
 Let's keep this on the list in case it helps someone else.

 On Fri, May 07, 2010 at 10:27:16PM +0100, Magnus Therning wrote:
 On 07/05/10 17:24, Tyler Roscoe wrote:
  On Fri, May 07, 2010 at 04:41:23PM +0100, Magnus Therning wrote:
         add_custom_command (TARGET ${PROJECT_NAME}
             POST_BUILD
             # Call the runner script directly. By doing it this way, all 
  the
             # unit tests in the executable run at once. If we call CTest
             # here (like we do for the _runtest target), the script (and
             # thus the python interpreter) is invoked once for each test 
  in
             # the executable, which is slower than calling the script 
  once.
             COMMAND ${PYTHON_EXECUTABLE} ${${PROJECT_NAME}_TESTRUNNER} 
  ${CMAKE_CFG_INTDIR} --gtest_print_time
         )
 
  One thing though, it seems the command is run *always* irrespective of
  whether the target is built or not.  That doesn't seem to square up
  with the text in the man page:
 
  Works For Me. I only see unit test runs if the library in question is
  recompiled or relinked. What version of CMake are you using?

 2.8

 What kind of target is ${PROJECT_NAME}?

 I used a target created with add_custom_target, so maybe that's the cause of 
 it.

 I think all the targets in our project which use this post-build step
 are libraries or executables.

 If your target is a custom_target that always runs (which, as noted in
 the docs, custom_targets sometimes do) then of course the post-build
 step will also always run.

I'm still having problems with this.

I put together this:

project( test-post-build NONE )
cmake_minimum_required( VERSION 2.8 )

set( output ${CMAKE_CURRENT_BINARY_DIR}/foo )
add_custom_command( OUTPUT ${output}
COMMAND touch ${output}
COMMENT Touching foo
)
add_custom_target( foo.build ALL DEPENDS ${output} )

add_custom_command( TARGET ${output}
POST_BUILD
COMMAND echo POST_BUILD ${output}
)

add_custom_command( TARGET foo.build
POST_BUILD
COMMAND echo POST_BUILD foo.build
)

Based on your description above I expected this behaviour:

% cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/magnus/Play/test/cmake/post_build/_build
% make
Scanning dependencies of target foo.build
[  0%] Touching foo
POST_BUILD /home/magnus/Play/test/cmake/post_build/_build/foo
POST_BUILD foo.build
[100%] Built target foo.build
% make
POST_BUILD foo.build
[100%] Built target foo.build

However, that's not the case.  I only ever see the 'POST_BUILD foo.build'
printed.  So, what target can I use to get the desired behaviour of the
POST_BUILD only being run after an actual build?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Unit tests, but not CTest

2010-05-07 Thread Magnus Therning
On Tue, Apr 27, 2010 at 15:50, Tyler Roscoe ty...@cryptio.net wrote:
 On Tue, Apr 27, 2010 at 02:47:18PM +0100, Magnus Therning wrote:
 Except of course that it will take away one of the things I *really*
 want, which is that all unit tests are run every time I compile.

 We run our unit tests with a python wrapper script that does some
 environment configuration before running the test. We then add this
 script as a post_build custom command so that the unit test runs after
 it compiles.

        add_custom_command (TARGET ${PROJECT_NAME}
            POST_BUILD
            # Call the runner script directly. By doing it this way, all the
            # unit tests in the executable run at once. If we call CTest
            # here (like we do for the _runtest target), the script (and
            # thus the python interpreter) is invoked once for each test in
            # the executable, which is slower than calling the script once.
            COMMAND ${PYTHON_EXECUTABLE} ${${PROJECT_NAME}_TESTRUNNER} 
 ${CMAKE_CFG_INTDIR} --gtest_print_time
        )

That does what I want, thanks for that tip.

One thing though, it seems the command is run *always* irrespective of
whether the target is built or not.  That doesn't seem to square up
with the text in the man page:

The command becomes part of the target and will only execute when
the target itself is built. If the target is already built, the
command will not execute.

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Unit tests, but not CTest

2010-04-27 Thread Magnus Therning
On Mon, Apr 26, 2010 at 20:56, Alexander Neundorf
a.neundorf-w...@gmx.net wrote:
 On Friday 23 April 2010, Magnus Therning wrote:
 2010/4/23 Adolfo Rodríguez Tsouroukdissian
 adolfo.rodrig...@pal-robotics.com:
  On Fri, Apr 23, 2010 at 5:56 PM, Magnus Therning mag...@therning.org
 
  wrote:
  On Fri, Apr 23, 2010 at 16:35, Tyler Roscoe ty...@cryptio.net wrote:
   On Fri, Apr 23, 2010 at 04:24:06PM +0100, Magnus Therning wrote:
   A project that I'm currently trying to convert over to CMake has
   several unit tests written as standalone executables.  Are there any
   examples around for integrating the running of such tests as part of
   the build in CMake?
  
   add_test just takes a command line. You can put whatever you want in
   there and ctest will run it for you.
  
   http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_test
 
  Ah, yes, that comes closer to what I want.  Thanks.  Now I only want
  the test's stdout to be connected to the stdout so I can see the
  results immediately
 
  Run ctest with the -V or -VV option

 Hmm, how do I get that passed to ctest when I run 'make test'?

 Don't run make test, but run ctest directly (that's also what make test
 does). You have a lot more options available when running ctest directly,
 it's worth it :-)

Except of course that it will take away one of the things I *really*
want, which is that all unit tests are run every time I compile.

It seems at the moment I'll have to write a stand-alone script to get
that behaviour :-(

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Is full language support possible?

2010-04-26 Thread Magnus Therning
What is needed to make it possible to write

project( camlzip MyLanguage )

and then have all the standard macros, add_libary() etc, do the correct thing
for MyLanguage?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe



signature.asc
Description: OpenPGP digital signature
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Some questions about dependencies

2010-04-23 Thread Magnus Therning
Does INSTALL( FILES ... ) have the same limitations regarding the location of
the commands that generate the files in question as ADD_CUSTOM_COMMAND( ...
DEPENDS ... ) has?

That is, proper dependencies for the files given to INSTALL will only be
generated when the files are the output of a custom command in the same
directory.

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] A target for 'install'?

2010-04-23 Thread Magnus Therning
Is there a target for 'install' that I can add dependencies to by
using add_dependencies()?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Unit tests, but not CTest

2010-04-23 Thread Magnus Therning
A project that I'm currently trying to convert over to CMake has
several unit tests written as standalone executables.  Are there any
examples around for integrating the running of such tests as part of
the build in CMake?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Unit tests, but not CTest

2010-04-23 Thread Magnus Therning
On Fri, Apr 23, 2010 at 16:35, Tyler Roscoe ty...@cryptio.net wrote:
 On Fri, Apr 23, 2010 at 04:24:06PM +0100, Magnus Therning wrote:
 A project that I'm currently trying to convert over to CMake has
 several unit tests written as standalone executables.  Are there any
 examples around for integrating the running of such tests as part of
 the build in CMake?

 add_test just takes a command line. You can put whatever you want in
 there and ctest will run it for you.

 http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_test

Ah, yes, that comes closer to what I want.  Thanks.  Now I only want
the test's stdout to be connected to the stdout so I can see the
results immediately

/M.

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Unit tests, but not CTest

2010-04-23 Thread Magnus Therning
2010/4/23 Adolfo Rodríguez Tsouroukdissian adolfo.rodrig...@pal-robotics.com:


 On Fri, Apr 23, 2010 at 5:56 PM, Magnus Therning mag...@therning.org
 wrote:

 On Fri, Apr 23, 2010 at 16:35, Tyler Roscoe ty...@cryptio.net wrote:
  On Fri, Apr 23, 2010 at 04:24:06PM +0100, Magnus Therning wrote:
  A project that I'm currently trying to convert over to CMake has
  several unit tests written as standalone executables.  Are there any
  examples around for integrating the running of such tests as part of
  the build in CMake?
 
  add_test just takes a command line. You can put whatever you want in
  there and ctest will run it for you.
 
  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_test

 Ah, yes, that comes closer to what I want.  Thanks.  Now I only want
 the test's stdout to be connected to the stdout so I can see the
 results immediately

 Run ctest with the -V or -VV option

Hmm, how do I get that passed to ctest when I run 'make test'?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] shell in Unix Makefiles

2010-04-22 Thread Magnus Therning
On Thu, Apr 22, 2010 at 08:38, naryniecki narynie...@o2.pl wrote:
 Hi,

 I have a lot of generated files in one folder. All this files must be in one 
 library. When I generate Unix Makefiles I get input line too long error while 
 linking. When I use NMake Makefile it works. As far as know this error 
 correspond to shell/console that is used while linking. Is it possible to 
 generate Unix Makefiles that use shell as in NMake makefile generator?

Depending on the linker it's sometimes possible to put the arguments
in a file (e.g. @file for GNU ld, IIRC).  Maybe that would be a way to
solve your problem here?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] shell in Unix Makefiles

2010-04-22 Thread Magnus Therning
On Thu, Apr 22, 2010 at 10:23, naryniecki narynie...@o2.pl wrote:
 Hi,

 I know there is such possibility, but I have also few directories with
 which are compiled and linked in normal way. In such situation I
 would have to create custom target for this big directory. But I had
 problem how to create target which say: compile all *.cpp files from
 directory to .o files.  I tried to use CMAKE_C_COMPILE_OBJECT somehow
 or CMAKE_C_FLAGS but it didn't work. I had \ signs in CMAKE_C_FLAGS
 and couldn't remove. I wrote to this list some time ago but no answer.

I'm not quite sure I understand what you are trying to do.  AFAIU your
goal is to do the following:

 - compile every C++ file in the directory
 - link the resulting object files into a library

Is that correct?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Looking for a way to do 'make install' to a destination

2010-04-19 Thread Magnus Therning
It's some times useful to do an install rooted not at '/' but at some
arbitrary location.  Is there some way of doing this with the GNU
makefiles generated by cmake?

Something like auto*'s 'make install DESTDIR=/where/I/want/it'?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Looking for a way to do 'make install' to a destination

2010-04-19 Thread Magnus Therning
On Mon, Apr 19, 2010 at 11:36, Remy Chibois rchib...@gmail.com wrote:

 On Apr 19, 2010, at 12:16 PM, Magnus Therning wrote:

 It's some times useful to do an install rooted not at '/' but at some
 arbitrary location.  Is there some way of doing this with the GNU
 makefiles generated by cmake?

 Something like auto*'s 'make install DESTDIR=/where/I/want/it'?

 Once a project has been configured, cmake_install.cmake contains support 
 for it.

 I use the following command line to use it:

 make -f Makefile DESTDIR=/foo/bar/whatever install

Thanks, that's what I was looking for.

Are there other make-time variables (as opposed to configure-time
variables) that are worth knowing about?  Is there a reference for
them anywhere?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] OCaml support in CMake?

2010-03-10 Thread Magnus Therning
I'm completely new to CMake, even though I've heard of it before this
is the first time I have a closer look at it.  Actually this was
prompted by the interview in FLOSS Weekly :-)

Currently I have a rather large OCaml project, which uses OMake.
There are several things I'd like to improve on the build system, the
most pressing being to add generation of RPMs.  CMake seems to offer
some very compelling improvements over OMake, including built-in
support for generating RPMs :-)

I found a discussion on this mailing list from January this year on
adding OCaml support[1], but that seems to have died out without any
clear resolution.  I also had a quick look at the CMake source tree
and found no mention of OCaml among the file names.

What is the current state of OCaml support in CMake?

If it's still non-existent what options do I have?  (I should probably
make clear that I'd *really* want to avoid having to write any macros
myself.  Using macros copied from some other project would be much
better ;-)

/M

[1]: http://www.mail-archive.com/cmake@cmake.org/msg26809.html

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake