[CMake] Generate Eclipse project with support for c++ 11

2014-12-05 Thread Luca Gherardi
Hi all,

I’m writing a CMake file for a project that should be compiled both in Ubuntu 
and OS X.
I want to use eclipse as IDE, gcc and C++ 11.

I read different threads that suggest how to enable C++ 11 in eclipse.
According to them I included these lines in my CMake:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")

if (${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4")
set(CMAKE_CXX_COMPILER_ARG1 "-std=c++11" CACHE STRING "C++ version for 
eclipse" FORCE)
set(CMAKE_ECLIPSE_VERSION "4.3" CACHE STRING "Eclipse version" FORCE)
endif (${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4”)

However, eclipse still set a wrong value for the symbol __cplusplus (199711L 
instead of 201103L I guess).
For this reason eclipse is not able to index C++ 11 features such as shared 
pointer.
Therefore I get a syntax error also if the code compiles.

Any idea on how can I address this issue?

Thanks,
Luca




-- 

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] Correct settings to add docopt.cpp to target list

2014-12-05 Thread Adam Getchell
It turns out that CGAL's CGAL_CreateSingleSourceCGALProgram.cmake module
handles this nicely:

create_single_source_cgal_program( "src/cdt-docopt.cpp"
"src/docopt/docopt.cpp")

does the trick.

Thanks for your consideration!

On Thu, Dec 4, 2014 at 10:54 PM, Adam Getchell 
wrote:

> I should note that I'm doing an out of source build, and that for my
> project the following line works:
>
> ┌─[*adam*][Hapkido][*±*][docopt *✓*][~/CDT-plusplus/build]
>
> └─▪ clang++ --std=c++11 --stdlib=libc++ -I ../src/docopt
> ../src/docopt/docopt.cpp ../src/cdt-docopt.cpp -o cdt_docopt
>
> On Thu, Dec 4, 2014 at 9:30 PM, Adam Getchell 
> wrote:
>
>> Hello all,
>>
>> I’m trying to use the docopt.cpp parser for my project[1]:
>>
>> https://github.com/docopt/docopt.cpp
>>
>> The usual invocation to build works:
>>
>> ┌─[*adam*][Hapkido][*±*][docopt *✗*][~/CDT-plusplus/src/docopt]
>> └─▪ clang++ --std=c++11 --stdlib=libc++ -I . docopt.cpp
>> examples/naval_fate.cpp -o naval_fate
>>
>> So, I want to add docopt.cpp and have the compiler look for header files
>> in the same directory, and add that to my executable.
>>
>> So far, what I’ve attempted is to add the lines:
>>
>> include_directories (BEFORE "src/docopt")
>> add_library(docopt.cpp "src/docopt/docopt.cpp”)
>>
>> My program uses CGAL[2], and all of those library headers are
>> incorporated using the create_single_source_cgal_program function in the
>> CGAL_CreateSingleSourceCGALProgram.cmake module.
>>
>> The error messages I’m getting correspond to the ones I get when
>> docopt.cpp is not included:
>>
>> ┌─[*adam*][Hapkido][*±*][docopt *✗*][~/CDT-plusplus/src/docopt]
>> └─▪ clang++ --std=c++11 --stdlib=libc++ -I . examples/naval_fate.cpp -o
>> naval_fate
>> Undefined symbols for architecture x86_64:
>>   "docopt::docopt(std::__1::basic_string> std::__1::char_traits, std::__1::allocator > const&,
>> std::__1::vector,
>> std::__1::allocator >,
>> std::__1::allocator> std::__1::char_traits, std::__1::allocator > > > const&, bool,
>> std::__1::basic_string,
>> std::__1::allocator > const&, bool)", referenced from:
>>   _main in naval_fate-780283.o
>>   "docopt::operator<<(std::__1::basic_ostream> std::__1::char_traits >&, docopt::value const&)", referenced from:
>>   _main in naval_fate-780283.o
>> ld: symbol(s) not found for architecture x86_64
>> clang: error: linker command failed with exit code 1 (use -v to see
>> invocation)
>>
>> Compare to:
>>
>> ┌─[*adam*][Hapkido][*±*][docopt *✗*][~/CDT-plusplus]
>> └─▪ ./build.sh
>> -- The C compiler identification is AppleClang 6.0.0.654
>> -- The CXX compiler identification is AppleClang 6.0.0.654
>> -- Check for working C compiler using: Ninja
>> -- Check for working C compiler using: Ninja -- works
>> -- Detecting C compiler ABI info
>> -- Detecting C compiler ABI info - done
>> -- Check for working CXX compiler using: Ninja
>> -- Check for working CXX compiler using: Ninja -- works
>> -- Detecting CXX compiler ABI info
>> -- Detecting CXX compiler ABI info - done
>> -- Build type: Release
>> -- USING CXXFLAGS = ' -O3 -DNDEBUG'
>> -- USING EXEFLAGS = '
>> -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
>> '
>> -- Targetting Ninja
>> -- Using /usr/bin/c++ compiler.
>> -- DARWIN_VERSION=14
>> -- Mac Leopard detected
>> -- Requested component: Core
>> -- Requested component: MPFR
>> -- Requested component: GMP
>> -- Found Eigen3: /usr/local/include/eigen3 (found suitable version
>> "3.2.2", minimum required is "3.1.0")
>> -- Configuring done
>> -- Generating done
>> -- Build files have been written to: /Users/adam/CDT-plusplus/build
>> [10/13] Linking CXX executable cdt-docopt
>> FAILED: : && /usr/bin/c++   -O3 -DNDEBUG -Wl,-search_paths_first
>> -Wl,-headerpad_max_install_names
>> -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
>> CMakeFiles/cdt-docopt.dir/src/cdt-docopt.cpp.o  -o cdt-docopt
>> -L/Users/adam/gmock-1.7.0/lib/.libs
>> -L/Users/adam/gmock-1.7.0/gtest/lib/.libs /usr/local/lib/libmpfr.dylib
>> /usr/local/lib/libgmp.dylib /usr/local/lib/libCGAL_Core.dylib
>> /usr/local/lib/libCGAL.dylib /usr/local/lib/libboost_thread-mt.dylib
>> /usr/local/lib/libboost_system-mt.dylib /usr/local/lib/libCGAL_Core.dylib
>> /usr/local/lib/libCGAL.dylib /usr/local/lib/libboost_thread-mt.dylib
>> /usr/local/lib/libboost_system-mt.dylib
>> -Wl,-rpath,/Users/adam/gmock-1.7.0/lib/.libs
>> -Wl,-rpath,/Users/adam/gmock-1.7.0/gtest/lib/.libs && :
>> Undefined symbols for architecture x86_64:
>>   "docopt::docopt(std::__1::basic_string> std::__1::char_traits, std::__1::allocator > const&,
>> std::__1::vector,
>> std::__1::allocator >,
>> std::__1::allocator> std::__1::char_traits, std::__1::allocator > > > const&, bool,
>> std::__1::basic_string,
>> std::__1::allocator > const&, bool)", refe

Re: [CMake] Visual Studio 12 C++ Compiler Detection

2014-12-05 Thread Jakub Zakrzewski

> So, it appears to find the compiler OK since it emits the correct compiler 
> identification. But, the actual value of CMAKE_CXX_COMPILER is not usable. If 
> you try to execute
> C:/Program…./x86_amd64/cl.exe from within a CMake script or even from the 
> command line, it will fail and produce the well-known “0xc07b” dialog 
> (missing DLL). Unless you’ve sourced > vcvarsx86_amd64.bat, the correct 
> environment variables are not set for this version of the compiler.

> On the other hand, if I do “cmake –G NMake Makefiles”, I get what I expect:

> Namely, it finds C:/Program…./amd64/cl.exe.

> I would like to see how it is coming up with this version of the compiler 
> which isn’t even in the PATH.

Hi Allen,

CMake does not pay attention to the PATH when you ask for VisualStudio 
generator. It simply finds it using it's internal logic. The generated projects 
are suitable for opening in the IDE.
The NMake generator behaves much more like Unix Makefiles generator, so it is 
sensitive to the environment variables and remembers all variables it needs.

--
Gruesse,
Jakub





-- 

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] Get native build command with CMake 3+

2014-12-05 Thread Petr Kmoch
Hi all.

I'm converting a small Makefile-based project to CMake. The project is not
mine, so I am trying to match its existing buildsystem as closely as
possible.

One of the rules in the original Makefile is (simplified) as follows:

examples: all
  make -C example_dir all

This gives a target 'examples' in the top-level Makefile, which is not
included in 'all', but can be used to build all examples. I would like to
achieve something similar with CMake.

I added example_dir/CMakeLists.txt, which includes a project() command and
defines all the targets for example executables. In the toplevel CMakeList,
I did this:

# Add the subdirectory but don't include its targets by default
add_subdirectory(example_dir EXCLUDE_FROM_ALL)

# Add a custom target to build all examples
add_custom_target(examples ???)

I'm stuck at the custom target. What I need for its command is a
generator-agnostic equivalent for 'make -C example_dir all' (or 'make -f
example_dir/Makefile all').

I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...', but
this complains that example_dir does not contain a CMakeCache.txt (which is
correct of course, it's not the toplevel directory). Then I remembered that
build_command() can be used to get a command line to build a project;
unfortunately, in 3.0 and later, this just returns 'cmake --build ...' and
so is unusable in my situation.

Is there a way to query CMake for the native command line (or something
else) I could use to build the CMake-generated buildsystem in the
subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that doesn't
tell me anything about what arguments I should pass, and it's not even set
on Visual Studio generators.

As a workaround, I thought of not doing add_subdirectory() at all and
instead adding a custom target with 'ctest --build-and-test ...', but I
would prefer to configure & generate the two directories together. I plan
to eventually add install() rules for the examples as well, and the
examples also use one of the targets from the toplevel cmakelist in
add_custom_command(OUTPUT ...), so I would really like to keep them as one
CMake system. Is there a way to do so?

Petr
-- 

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 native build command with CMake 3+

2014-12-05 Thread David Cole via CMake
Try:

cmake --build . --target examples

(where "." represents the current working directory, and assumes
you're in the top level build tree...)


On Fri, Dec 5, 2014 at 5:46 AM, Petr Kmoch  wrote:
> Hi all.
>
> I'm converting a small Makefile-based project to CMake. The project is not
> mine, so I am trying to match its existing buildsystem as closely as
> possible.
>
> One of the rules in the original Makefile is (simplified) as follows:
>
> examples: all
>   make -C example_dir all
>
> This gives a target 'examples' in the top-level Makefile, which is not
> included in 'all', but can be used to build all examples. I would like to
> achieve something similar with CMake.
>
> I added example_dir/CMakeLists.txt, which includes a project() command and
> defines all the targets for example executables. In the toplevel CMakeList,
> I did this:
>
> # Add the subdirectory but don't include its targets by default
> add_subdirectory(example_dir EXCLUDE_FROM_ALL)
>
> # Add a custom target to build all examples
> add_custom_target(examples ???)
>
> I'm stuck at the custom target. What I need for its command is a
> generator-agnostic equivalent for 'make -C example_dir all' (or 'make -f
> example_dir/Makefile all').
>
> I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...', but
> this complains that example_dir does not contain a CMakeCache.txt (which is
> correct of course, it's not the toplevel directory). Then I remembered that
> build_command() can be used to get a command line to build a project;
> unfortunately, in 3.0 and later, this just returns 'cmake --build ...' and
> so is unusable in my situation.
>
> Is there a way to query CMake for the native command line (or something
> else) I could use to build the CMake-generated buildsystem in the
> subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that doesn't
> tell me anything about what arguments I should pass, and it's not even set
> on Visual Studio generators.
>
> As a workaround, I thought of not doing add_subdirectory() at all and
> instead adding a custom target with 'ctest --build-and-test ...', but I
> would prefer to configure & generate the two directories together. I plan to
> eventually add install() rules for the examples as well, and the examples
> also use one of the targets from the toplevel cmakelist in
> add_custom_command(OUTPUT ...), so I would really like to keep them as one
> CMake system. Is there a way to do so?
>
> Petr
>
> --
>
> 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
-- 

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] Visual Studio 12 C++ Compiler Detection

2014-12-05 Thread Allen Barnett
Hi Jakub: Thanks for the tip. What is the proper way to execute the compiler 
during the initial configure step? try_compile?

Thanks,
Allen

> So, it appears to find the compiler OK since it emits the correct compiler 
> identification. But, the actual value of CMAKE_CXX_COMPILER is not usable. If 
> you try to execute 
> C:/Program…./x86_amd64/cl.exe from within a CMake script or even from the 
> command line, it will fail and produce the well-known “0xc07b” dialog 
> (missing DLL). Unless you’ve sourced > vcvarsx86_amd64.bat, the correct 
> environment variables are not set for this version of the compiler.

> On the other hand, if I do “cmake –G NMake Makefiles”, I get what I expect:

> Namely, it finds C:/Program…./amd64/cl.exe.

> I would like to see how it is coming up with this version of the compiler 
> which isn’t even in the PATH.

Hi Allen,

CMake does not pay attention to the PATH when you ask for VisualStudio 
generator. It simply finds it using it's internal logic. The generated projects 
are suitable for opening in the IDE.
The NMake generator behaves much more like Unix Makefiles generator, so it is 
sensitive to the environment variables and remembers all variables it needs.


-- 

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 native build command with CMake 3+

2014-12-05 Thread Petr Kmoch
I assume you actually meant 'cmake --build . --target example_dir', the
name of the directory. 'examples' is the name of the custom target; if that
target's command was to build itself, I believe it would become a fork bomb.

Anyway, I tried it with the directory name, it doesn't work. I'm generating
with VS2008, and devenv was complaining about "Invalid project." Which kind
of makes sense, there is no 'example_dir' project in the solution.

On Fri, Dec 5, 2014 at 2:59 PM, David Cole  wrote:

> Try:
>
> cmake --build . --target examples
>
> (where "." represents the current working directory, and assumes
> you're in the top level build tree...)
>
>
> On Fri, Dec 5, 2014 at 5:46 AM, Petr Kmoch  wrote:
> > Hi all.
> >
> > I'm converting a small Makefile-based project to CMake. The project is
> not
> > mine, so I am trying to match its existing buildsystem as closely as
> > possible.
> >
> > One of the rules in the original Makefile is (simplified) as follows:
> >
> > examples: all
> >   make -C example_dir all
> >
> > This gives a target 'examples' in the top-level Makefile, which is not
> > included in 'all', but can be used to build all examples. I would like to
> > achieve something similar with CMake.
> >
> > I added example_dir/CMakeLists.txt, which includes a project() command
> and
> > defines all the targets for example executables. In the toplevel
> CMakeList,
> > I did this:
> >
> > # Add the subdirectory but don't include its targets by default
> > add_subdirectory(example_dir EXCLUDE_FROM_ALL)
> >
> > # Add a custom target to build all examples
> > add_custom_target(examples ???)
> >
> > I'm stuck at the custom target. What I need for its command is a
> > generator-agnostic equivalent for 'make -C example_dir all' (or 'make -f
> > example_dir/Makefile all').
> >
> > I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...', but
> > this complains that example_dir does not contain a CMakeCache.txt (which
> is
> > correct of course, it's not the toplevel directory). Then I remembered
> that
> > build_command() can be used to get a command line to build a project;
> > unfortunately, in 3.0 and later, this just returns 'cmake --build ...'
> and
> > so is unusable in my situation.
> >
> > Is there a way to query CMake for the native command line (or something
> > else) I could use to build the CMake-generated buildsystem in the
> > subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that doesn't
> > tell me anything about what arguments I should pass, and it's not even
> set
> > on Visual Studio generators.
> >
> > As a workaround, I thought of not doing add_subdirectory() at all and
> > instead adding a custom target with 'ctest --build-and-test ...', but I
> > would prefer to configure & generate the two directories together. I
> plan to
> > eventually add install() rules for the examples as well, and the examples
> > also use one of the targets from the toplevel cmakelist in
> > add_custom_command(OUTPUT ...), so I would really like to keep them as
> one
> > CMake system. Is there a way to do so?
> >
> > Petr
> >
> > --
> >
> > 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
>
-- 

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 native build command with CMake 3+

2014-12-05 Thread Micha Hergarden
Hello Petr,

In your example the original make command simply states that it should
switch to the example_dir and build an 'all' target there. It does not
specify how this target is build. That is the part that should end up in
your custom command. You can name the command 'examples', set WORKING_DIR
to the example_dir and then perform the steps needed to build. If you want
that to be a separate cmake based solution, you may want to take a look at
the external_project module.

With kind regards,
Micha Hergarden

2014-12-05 11:46 GMT+01:00 Petr Kmoch :

> Hi all.
>
> I'm converting a small Makefile-based project to CMake. The project is not
> mine, so I am trying to match its existing buildsystem as closely as
> possible.
>
> One of the rules in the original Makefile is (simplified) as follows:
>
> examples: all
>   make -C example_dir all
>
> This gives a target 'examples' in the top-level Makefile, which is not
> included in 'all', but can be used to build all examples. I would like to
> achieve something similar with CMake.
>
> I added example_dir/CMakeLists.txt, which includes a project() command and
> defines all the targets for example executables. In the toplevel CMakeList,
> I did this:
>
> # Add the subdirectory but don't include its targets by default
> add_subdirectory(example_dir EXCLUDE_FROM_ALL)
>
> # Add a custom target to build all examples
> add_custom_target(examples ???)
>
> I'm stuck at the custom target. What I need for its command is a
> generator-agnostic equivalent for 'make -C example_dir all' (or 'make -f
> example_dir/Makefile all').
>
> I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...', but
> this complains that example_dir does not contain a CMakeCache.txt (which is
> correct of course, it's not the toplevel directory). Then I remembered that
> build_command() can be used to get a command line to build a project;
> unfortunately, in 3.0 and later, this just returns 'cmake --build ...' and
> so is unusable in my situation.
>
> Is there a way to query CMake for the native command line (or something
> else) I could use to build the CMake-generated buildsystem in the
> subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that doesn't
> tell me anything about what arguments I should pass, and it's not even set
> on Visual Studio generators.
>
> As a workaround, I thought of not doing add_subdirectory() at all and
> instead adding a custom target with 'ctest --build-and-test ...', but I
> would prefer to configure & generate the two directories together. I plan
> to eventually add install() rules for the examples as well, and the
> examples also use one of the targets from the toplevel cmakelist in
> add_custom_command(OUTPUT ...), so I would really like to keep them as one
> CMake system. Is there a way to do so?
>
> Petr
>
> --
>
> 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
>
-- 

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 native build command with CMake 3+

2014-12-05 Thread Hendrik Sattler
Hi,

this original makefile rule was probably just a simplification.
Make your custom target depend on all example targets which link the desired 
parts, then you get what the original makefile author just didn't want to do 
manually: having built all examples and their dependencies.
And it's less ugly...

HS


Am 5. Dezember 2014 11:46:03 MEZ, schrieb Petr Kmoch :
>Hi all.
>
>I'm converting a small Makefile-based project to CMake. The project is
>not
>mine, so I am trying to match its existing buildsystem as closely as
>possible.
>
>One of the rules in the original Makefile is (simplified) as follows:
>
>examples: all
>  make -C example_dir all
>
>This gives a target 'examples' in the top-level Makefile, which is not
>included in 'all', but can be used to build all examples. I would like
>to
>achieve something similar with CMake.
>
>I added example_dir/CMakeLists.txt, which includes a project() command
>and
>defines all the targets for example executables. In the toplevel
>CMakeList,
>I did this:
>
># Add the subdirectory but don't include its targets by default
>add_subdirectory(example_dir EXCLUDE_FROM_ALL)
>
># Add a custom target to build all examples
>add_custom_target(examples ???)
>
>I'm stuck at the custom target. What I need for its command is a
>generator-agnostic equivalent for 'make -C example_dir all' (or 'make
>-f
>example_dir/Makefile all').
>
>I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...',
>but
>this complains that example_dir does not contain a CMakeCache.txt
>(which is
>correct of course, it's not the toplevel directory). Then I remembered
>that
>build_command() can be used to get a command line to build a project;
>unfortunately, in 3.0 and later, this just returns 'cmake --build ...'
>and
>so is unusable in my situation.
>
>Is there a way to query CMake for the native command line (or something
>else) I could use to build the CMake-generated buildsystem in the
>subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that
>doesn't
>tell me anything about what arguments I should pass, and it's not even
>set
>on Visual Studio generators.
>
>As a workaround, I thought of not doing add_subdirectory() at all and
>instead adding a custom target with 'ctest --build-and-test ...', but I
>would prefer to configure & generate the two directories together. I
>plan
>to eventually add install() rules for the examples as well, and the
>examples also use one of the targets from the toplevel cmakelist in
>add_custom_command(OUTPUT ...), so I would really like to keep them as
>one
>CMake system. Is there a way to do so?
>
>Petr
>
>
>
>
>-- 
>
>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
-- 

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 native build command with CMake 3+

2014-12-05 Thread Petr Kmoch
Hi Micha.

I understand how the original works, and I know I can work around it with a
separate buildsystem (using e.g. ExternalProject_Add() or ctest
--build-and-test). I was just wondering: since CMake generates a .sln (or
Makefile) in the subdirectory (because I put a project() call in there),
does it somehow offer a way to build the 'all' target from that solution
(or Makefile)?

Petr

On Fri, Dec 5, 2014 at 3:42 PM, Micha Hergarden 
wrote:

> Hello Petr,
>
> In your example the original make command simply states that it should
> switch to the example_dir and build an 'all' target there. It does not
> specify how this target is build. That is the part that should end up in
> your custom command. You can name the command 'examples', set WORKING_DIR
> to the example_dir and then perform the steps needed to build. If you want
> that to be a separate cmake based solution, you may want to take a look at
> the external_project module.
>
> With kind regards,
> Micha Hergarden
>
> 2014-12-05 11:46 GMT+01:00 Petr Kmoch :
>
>> Hi all.
>>
>> I'm converting a small Makefile-based project to CMake. The project is
>> not mine, so I am trying to match its existing buildsystem as closely as
>> possible.
>>
>> One of the rules in the original Makefile is (simplified) as follows:
>>
>> examples: all
>>   make -C example_dir all
>>
>> This gives a target 'examples' in the top-level Makefile, which is not
>> included in 'all', but can be used to build all examples. I would like to
>> achieve something similar with CMake.
>>
>> I added example_dir/CMakeLists.txt, which includes a project() command
>> and defines all the targets for example executables. In the toplevel
>> CMakeList, I did this:
>>
>> # Add the subdirectory but don't include its targets by default
>> add_subdirectory(example_dir EXCLUDE_FROM_ALL)
>>
>> # Add a custom target to build all examples
>> add_custom_target(examples ???)
>>
>> I'm stuck at the custom target. What I need for its command is a
>> generator-agnostic equivalent for 'make -C example_dir all' (or 'make -f
>> example_dir/Makefile all').
>>
>> I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...', but
>> this complains that example_dir does not contain a CMakeCache.txt (which is
>> correct of course, it's not the toplevel directory). Then I remembered that
>> build_command() can be used to get a command line to build a project;
>> unfortunately, in 3.0 and later, this just returns 'cmake --build ...' and
>> so is unusable in my situation.
>>
>> Is there a way to query CMake for the native command line (or something
>> else) I could use to build the CMake-generated buildsystem in the
>> subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that doesn't
>> tell me anything about what arguments I should pass, and it's not even set
>> on Visual Studio generators.
>>
>> As a workaround, I thought of not doing add_subdirectory() at all and
>> instead adding a custom target with 'ctest --build-and-test ...', but I
>> would prefer to configure & generate the two directories together. I plan
>> to eventually add install() rules for the examples as well, and the
>> examples also use one of the targets from the toplevel cmakelist in
>> add_custom_command(OUTPUT ...), so I would really like to keep them as one
>> CMake system. Is there a way to do so?
>>
>> Petr
>>
>> --
>>
>> 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
>>
>
>
-- 

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 native build command with CMake 3+

2014-12-05 Thread David Cole via CMake
No, I meant exactly what I said.

--target takes a CMake target name.


HTH,
D



On Fri, Dec 5, 2014 at 9:23 AM, Petr Kmoch  wrote:
> I assume you actually meant 'cmake --build . --target example_dir', the name
> of the directory. 'examples' is the name of the custom target; if that
> target's command was to build itself, I believe it would become a fork bomb.
>
> Anyway, I tried it with the directory name, it doesn't work. I'm generating
> with VS2008, and devenv was complaining about "Invalid project." Which kind
> of makes sense, there is no 'example_dir' project in the solution.
>
> On Fri, Dec 5, 2014 at 2:59 PM, David Cole  wrote:
>>
>> Try:
>>
>> cmake --build . --target examples
>>
>> (where "." represents the current working directory, and assumes
>> you're in the top level build tree...)
>>
>>
>> On Fri, Dec 5, 2014 at 5:46 AM, Petr Kmoch  wrote:
>> > Hi all.
>> >
>> > I'm converting a small Makefile-based project to CMake. The project is
>> > not
>> > mine, so I am trying to match its existing buildsystem as closely as
>> > possible.
>> >
>> > One of the rules in the original Makefile is (simplified) as follows:
>> >
>> > examples: all
>> >   make -C example_dir all
>> >
>> > This gives a target 'examples' in the top-level Makefile, which is not
>> > included in 'all', but can be used to build all examples. I would like
>> > to
>> > achieve something similar with CMake.
>> >
>> > I added example_dir/CMakeLists.txt, which includes a project() command
>> > and
>> > defines all the targets for example executables. In the toplevel
>> > CMakeList,
>> > I did this:
>> >
>> > # Add the subdirectory but don't include its targets by default
>> > add_subdirectory(example_dir EXCLUDE_FROM_ALL)
>> >
>> > # Add a custom target to build all examples
>> > add_custom_target(examples ???)
>> >
>> > I'm stuck at the custom target. What I need for its command is a
>> > generator-agnostic equivalent for 'make -C example_dir all' (or 'make -f
>> > example_dir/Makefile all').
>> >
>> > I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...', but
>> > this complains that example_dir does not contain a CMakeCache.txt (which
>> > is
>> > correct of course, it's not the toplevel directory). Then I remembered
>> > that
>> > build_command() can be used to get a command line to build a project;
>> > unfortunately, in 3.0 and later, this just returns 'cmake --build ...'
>> > and
>> > so is unusable in my situation.
>> >
>> > Is there a way to query CMake for the native command line (or something
>> > else) I could use to build the CMake-generated buildsystem in the
>> > subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that doesn't
>> > tell me anything about what arguments I should pass, and it's not even
>> > set
>> > on Visual Studio generators.
>> >
>> > As a workaround, I thought of not doing add_subdirectory() at all and
>> > instead adding a custom target with 'ctest --build-and-test ...', but I
>> > would prefer to configure & generate the two directories together. I
>> > plan to
>> > eventually add install() rules for the examples as well, and the
>> > examples
>> > also use one of the targets from the toplevel cmakelist in
>> > add_custom_command(OUTPUT ...), so I would really like to keep them as
>> > one
>> > CMake system. Is there a way to do so?
>> >
>> > Petr
>> >
>> > --
>> >
>> > 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
>
>
-- 

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 native build command with CMake 3+

2014-12-05 Thread Petr Kmoch
OK, sorry for misunderstanding. But then I don't have a target like this.
Basically, I am trying to create a custom target that would do this:

# When using Makefile generator
add_custom_target(
  examples
  COMMAND make -C example_dir all
  VERBATIM
)

# When using vs2008 generator
add_custom_target(
  examples
  COMMAND devenv Examples.sln /Build /Project:ALL_BUILD
/ProjectConfig:$
  WORKING_DIRECTORY example_dir
  VERBATIM
)

# When using vs2010 generator, use msbuild
# etc...

without having to hardcode the logic (CMake must have this info inside
somewhere). So I am effectively trying to *create* the target 'examples'.

My current solution is to make the custom target empty and have it depend
on all the targets in example_dir. But this has two consequences I don't
like:
1. I have to collect the target names in example_dir/CMakeLists.txt, as it
has to communicate them to its parent
2. Being dependecies, the targets from example_dir show up in the toplevel
solution file/Makefile. I was trying to prevent that.

I looked at the commit message which changed build_command() from returning
the native command line to returning cmake --build, at it mentions the fact
that sometimes, the native tool has to be selected based on the contents of
the solution (devenv instead of msbuild when ifort is involved). So I guess
the only way to get what I want would be with a generator expression (one
which does not currently exist).

I guess I'll stick to my workaround with dependencies. But thanks for your
help.

Petr

On Fri, Dec 5, 2014 at 4:19 PM, David Cole  wrote:

> No, I meant exactly what I said.
>
> --target takes a CMake target name.
>
>
> HTH,
> D
>
>
>
> On Fri, Dec 5, 2014 at 9:23 AM, Petr Kmoch  wrote:
> > I assume you actually meant 'cmake --build . --target example_dir', the
> name
> > of the directory. 'examples' is the name of the custom target; if that
> > target's command was to build itself, I believe it would become a fork
> bomb.
> >
> > Anyway, I tried it with the directory name, it doesn't work. I'm
> generating
> > with VS2008, and devenv was complaining about "Invalid project." Which
> kind
> > of makes sense, there is no 'example_dir' project in the solution.
> >
> > On Fri, Dec 5, 2014 at 2:59 PM, David Cole  wrote:
> >>
> >> Try:
> >>
> >> cmake --build . --target examples
> >>
> >> (where "." represents the current working directory, and assumes
> >> you're in the top level build tree...)
> >>
> >>
> >> On Fri, Dec 5, 2014 at 5:46 AM, Petr Kmoch 
> wrote:
> >> > Hi all.
> >> >
> >> > I'm converting a small Makefile-based project to CMake. The project is
> >> > not
> >> > mine, so I am trying to match its existing buildsystem as closely as
> >> > possible.
> >> >
> >> > One of the rules in the original Makefile is (simplified) as follows:
> >> >
> >> > examples: all
> >> >   make -C example_dir all
> >> >
> >> > This gives a target 'examples' in the top-level Makefile, which is not
> >> > included in 'all', but can be used to build all examples. I would like
> >> > to
> >> > achieve something similar with CMake.
> >> >
> >> > I added example_dir/CMakeLists.txt, which includes a project() command
> >> > and
> >> > defines all the targets for example executables. In the toplevel
> >> > CMakeList,
> >> > I did this:
> >> >
> >> > # Add the subdirectory but don't include its targets by default
> >> > add_subdirectory(example_dir EXCLUDE_FROM_ALL)
> >> >
> >> > # Add a custom target to build all examples
> >> > add_custom_target(examples ???)
> >> >
> >> > I'm stuck at the custom target. What I need for its command is a
> >> > generator-agnostic equivalent for 'make -C example_dir all' (or 'make
> -f
> >> > example_dir/Makefile all').
> >> >
> >> > I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...',
> but
> >> > this complains that example_dir does not contain a CMakeCache.txt
> (which
> >> > is
> >> > correct of course, it's not the toplevel directory). Then I remembered
> >> > that
> >> > build_command() can be used to get a command line to build a project;
> >> > unfortunately, in 3.0 and later, this just returns 'cmake --build ...'
> >> > and
> >> > so is unusable in my situation.
> >> >
> >> > Is there a way to query CMake for the native command line (or
> something
> >> > else) I could use to build the CMake-generated buildsystem in the
> >> > subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that
> doesn't
> >> > tell me anything about what arguments I should pass, and it's not even
> >> > set
> >> > on Visual Studio generators.
> >> >
> >> > As a workaround, I thought of not doing add_subdirectory() at all and
> >> > instead adding a custom target with 'ctest --build-and-test ...', but
> I
> >> > would prefer to configure & generate the two directories together. I
> >> > plan to
> >> > eventually add install() rules for the examples as well, and the
> >> > examples
> >> > also use one of the targets from the toplevel cmakelist in
> >> > add_custom_command(OUTPUT .

[CMake] unexpected behavior with TARGET_FILE_DIR and Visual Studio 2010

2014-12-05 Thread Michael Ellery
Hi cmake-users,
 
I have the following setup:

CMAKE: 3.0.2
Visual Studio 2010

In one of my cmake files, I’m trying to create a preprocessor definition based 
on the TARGET_FILE_DIR of a different target … so I’m trying this:

target_compile_definitions(my_target_B PUBLIC 
  -DTARGET_A_DIR="$" 
)

When I run this for my visual studio build (2010), I get the following settings 
created in the project file:

test/my_target_B.vcxproj:95:  
WIN32;_WINDOWS;_DEBUG;_DEBUG;TARGET_A_DIR="Y:/work/some_lib/bld_win/src/my_target_A/Debug";CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)
test/my_target_B.vcxproj:99:  
WIN32;_WINDOWS;_DEBUG;_DEBUG;TARGET_A_DIR=\"Y:/work/some_lib/bld_win/src/my_target_A/Debug\";CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)
test/my_target_B.vcxproj:392:  
WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR="Y:/work/some_lib/bld_win/src/my_target_A/Debug";CMAKE_INTDIR="Release";%(PreprocessorDefinitions)
test/my_target_B.vcxproj:396:  
WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR=\"Y:/work/some_lib/bld_win/src/my_target_A/Debug\";CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)
test/my_target_B.vcxproj:689:  
WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR="Y:/work/some_lib/bld_win/src/my_target_A/Debug";CMAKE_INTDIR="MinSizeRel";%(PreprocessorDefinitions)
test/my_target_B.vcxproj:693:  
WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR=\"Y:/work/some_lib/bld_win/src/my_target_A/Debug\";CMAKE_INTDIR=\"MinSizeRel\";%(PreprocessorDefinitions)
test/my_target_B.vcxproj:986:  
WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR="Y:/work/some_lib/bld_win/src/my_target_A/Debug";CMAKE_INTDIR="RelWithDebInfo";%(PreprocessorDefinitions)
test/my_target_B.vcxproj:990:  
WIN32;_WINDOWS;NDEBUG;TARGET_A_DIR=\"Y:/work/some_lib/bld_win/src/my_target_A/Debug\";CMAKE_INTDIR=\"RelWithDebInfo\";%(PreprocessorDefinitions)

in other words, it looks like the generator expression is only being evaluated 
once (as Debug) and then used for ALL of the build configs in the visual studio 
project.  This isn’t exactly what I want since I need the actual output dir for 
each config to be the correct one for that build type.

This same thing works fine on my linux/makefile build since the output dir is 
the same for all builds.

Can anyone offer advice? Is this how the visual studio generator works or is 
this possibly a bug in CMake?

Thanks,
Mike


signature.asc
Description: Message signed with OpenPGP using GPGMail
-- 

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] project directive overwrites CMAKE_INSTALL_PREFIX?

2014-12-05 Thread Chris Johnson
Strangely, running "cmake -DCMAKE_INSTALL_PREFIX=/some/path" does NOT
rewrite the cmake_install.cmake, but does rewrite the CMakeCache.txt and
other files.  The result is a bad install path won't go away until one
manually removes the cmake_install.cmake file(s).

On Thu, Dec 4, 2014 at 9:48 PM, J Decker  wrote:

> I find it's better to define CMAKE_INSTALL_PREFIX on the command line when
> building
>
> I do have this bit of code...
>
> IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
>   SET(CMAKE_INSTALL_PREFIX
> ${CMAKE_BINARY_DIR}/../${CMAKE_BUILD_TYPE}_out CACHE PATH "Install
> default 'out' in this directory." FORCE
> )
> ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
>
>
> which keeps it from overwriting an already set value (from the command
> line); and make sure it's in the cache so cmake-gui can edit it...
>
> (if  project() does something with cmake_isnstall_prefix might also be a
> bug)
>
> On Thu, Dec 4, 2014 at 7:27 PM, Chris Johnson  wrote:
>
>> I have a global include file used by all of the CMakeLists.txt files in
>> my project. In it, I set the value of CMAKE_INSTALL_PREFIX, as well as a
>> number of other variables and functions.
>>
>> In my CMakeLists.txt file, I had this:
>>
>> cmake_minimum_require(VERSION 2.8.4)
>> include(global.inc)
>> project(whatever)
>>
>> When I run cmake, the value of CMAKE_INSTALL_PREFIX is lost! Instead, in
>> the resulting cmake_install.cmake file has been defaulted back to
>> /usr/local which is completely wrong.
>>
>> However, if I change the order to this:
>>
>> cmake_minimum_require(VERSION 2.8.4)
>> project(whatever)
>> include(global.inc)
>>
>> It appears to work.
>>
>> I find nothing in the documentation saying that the project() directive
>> will set CMAKE_INSTALL_PREFIX.
>>
>> Even more strangely, if I run cmake a second time with the first
>> configuration (include before project), it will rewrite cmake_install.cmake
>> with the correct value.
>> ​ ​
>> That is, the behavior of cmake appears to be different based on whether
>> the build directory is empty or already contains cmake_install.cmake and
>> CMakeCache.txt files
>> ​, even though they contain the wrong path value for
>> CMAKE_INSTALL_PREFIX.​
>>
>> What is going on here?
>>
>>
>>
>>
>>
>>
>> --
>>
>> 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
>>
>
>
-- 

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] Common language runtime

2014-12-05 Thread Apoorva Gaddagimath
Hi everyone,
I'm trying to add a .NET assembly reference to my CMake project. Various forums 
on Google suggested to use /clr. The problem I've found, is that while CMake 
sets the "Common Language RunTime Support" option in the C/C++ section of the 
configuration properties if "/clr" is in the CXX_FLAGS, it does not set the 
"Common Language RunTime Support" in the general configuration properties, and 
that causes problems with linking .NET references. Is there a different way to 
do this or a different approach> Would greatly appreciate any help on this.

Thanks

Apoorva Gaddagimath
Software Engineer
Markit On Demand

Markit

5718 Central Avenue
Boulder, CO 80301
+1 720-648-4907
apoorva.gaddagim...@markit.com
www.markit.com




This e-mail, including accompanying communications and attachments, is strictly 
confidential and only for the intended recipient. Any retention, use or 
disclosure not expressly authorised by Markit is prohibited. This email is 
subject to all waivers and other terms at the following link: 
http://www.markit.com/en/about/legal/email-disclaimer.page

Please visit http://www.markit.com/en/about/contact/contact-us.page for contact 
information on our offices worldwide.
-- 

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] Common language runtime

2014-12-05 Thread J Decker
To enable compiling as/with CLR...

SET_TARGET_PROPERTIES(bag PROPERTIES
  COMPILE_FLAGS  "/CLR" )
# need to set unicode characters...
add_definitions( -D_UNICODE -DUNICODE )

string( REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT}
)
string( REPLACE "/EHsc" "" CMAKE_C_FLAGS_INIT ${CMAKE_C_FLAGS_INIT} )
string( REPLACE "/EHs" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_INIT} )
string( REPLACE "/EHs" "" CMAKE_C_FLAGS_INIT ${CMAKE_C_FLAGS_INIT} )
string( REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG
${CMAKE_CXX_FLAGS_DEBUG} )
# cannot set CLR for C code anyway; only C++
#string( REPLACE "/RTC1" "/CLR" CMAKE_C_FLAGS_DEBUG
${CMAKE_C_FLAGS_DEBUG} )


set( FORCE_CXX ON )
force_cxx flag also forces compiling C as C++.

set_source_files_properties(${_SOURCES} PROPERTIES LANGUAGE CXX )



On Fri, Dec 5, 2014 at 1:11 PM, Apoorva Gaddagimath <
apoorva.gaddagim...@markit.com> wrote:

>  Hi everyone,
>
> I’m trying to add a .NET assembly reference to my CMake project. Various
> forums on Google suggested to use /clr. The problem I've found, is that
> while CMake sets the "Common Language RunTime Support" option in the C/C++
> section of the configuration properties if "/clr" is in the CXX_FLAGS, it
> does not set the "Common Language RunTime Support" in the general
> configuration properties, and that causes problems with linking .NET
> references. Is there a different way to do this or a different approach>
> Would greatly appreciate any help on this.
>
>
>
> Thanks
>
>
>
> Apoorva Gaddagimath
>
> Software Engineer
>
> Markit On Demand
>
>
>
> Markit
>
>
>
> 5718 Central Avenue
>
> Boulder, CO 80301
>
> +1 720-648-4907
>
> apoorva.gaddagim...@markit.com
>
> www.markit.com
>
>
>
> --
>
> This e-mail, including accompanying communications and attachments, is
> strictly confidential and only for the intended recipient. Any retention,
> use or disclosure not expressly authorised by Markit is prohibited. This
> email is subject to all waivers and other terms at the following link:
> http://www.markit.com/en/about/legal/email-disclaimer.page
>
> Please visit http://www.markit.com/en/about/contact/contact-us.page for
> contact information on our offices worldwide.
>
> --
>
> 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
>
-- 

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 native build command with CMake 3+

2014-12-05 Thread J Decker
Isn't it as smiple as

add_subdirectory( examples_dir ) which has it's own CMakeLists?
Does it really have to build as an extra step or would

OPTION( BUILD_EXAMPLES "Build Examples?" ON )

if( BUILD_EXAMPLES)
add_subdirectory( examples_dir)
endif( BUILD_EXAMPLES)

On Fri, Dec 5, 2014 at 7:41 AM, Petr Kmoch  wrote:

> OK, sorry for misunderstanding. But then I don't have a target like this.
> Basically, I am trying to create a custom target that would do this:
>
> # When using Makefile generator
> add_custom_target(
>   examples
>   COMMAND make -C example_dir all
>   VERBATIM
> )
>
> # When using vs2008 generator
> add_custom_target(
>   examples
>   COMMAND devenv Examples.sln /Build /Project:ALL_BUILD
> /ProjectConfig:$
>   WORKING_DIRECTORY example_dir
>   VERBATIM
> )
>
> # When using vs2010 generator, use msbuild
> # etc...
>
> without having to hardcode the logic (CMake must have this info inside
> somewhere). So I am effectively trying to *create* the target 'examples'.
>
> My current solution is to make the custom target empty and have it depend
> on all the targets in example_dir. But this has two consequences I don't
> like:
> 1. I have to collect the target names in example_dir/CMakeLists.txt, as it
> has to communicate them to its parent
> 2. Being dependecies, the targets from example_dir show up in the toplevel
> solution file/Makefile. I was trying to prevent that.
>
> I looked at the commit message which changed build_command() from
> returning the native command line to returning cmake --build, at it
> mentions the fact that sometimes, the native tool has to be selected based
> on the contents of the solution (devenv instead of msbuild when ifort is
> involved). So I guess the only way to get what I want would be with a
> generator expression (one which does not currently exist).
>
> I guess I'll stick to my workaround with dependencies. But thanks for your
> help.
>
> Petr
>
> On Fri, Dec 5, 2014 at 4:19 PM, David Cole  wrote:
>
>> No, I meant exactly what I said.
>>
>> --target takes a CMake target name.
>>
>>
>> HTH,
>> D
>>
>>
>>
>> On Fri, Dec 5, 2014 at 9:23 AM, Petr Kmoch  wrote:
>> > I assume you actually meant 'cmake --build . --target example_dir', the
>> name
>> > of the directory. 'examples' is the name of the custom target; if that
>> > target's command was to build itself, I believe it would become a fork
>> bomb.
>> >
>> > Anyway, I tried it with the directory name, it doesn't work. I'm
>> generating
>> > with VS2008, and devenv was complaining about "Invalid project." Which
>> kind
>> > of makes sense, there is no 'example_dir' project in the solution.
>> >
>> > On Fri, Dec 5, 2014 at 2:59 PM, David Cole  wrote:
>> >>
>> >> Try:
>> >>
>> >> cmake --build . --target examples
>> >>
>> >> (where "." represents the current working directory, and assumes
>> >> you're in the top level build tree...)
>> >>
>> >>
>> >> On Fri, Dec 5, 2014 at 5:46 AM, Petr Kmoch 
>> wrote:
>> >> > Hi all.
>> >> >
>> >> > I'm converting a small Makefile-based project to CMake. The project
>> is
>> >> > not
>> >> > mine, so I am trying to match its existing buildsystem as closely as
>> >> > possible.
>> >> >
>> >> > One of the rules in the original Makefile is (simplified) as follows:
>> >> >
>> >> > examples: all
>> >> >   make -C example_dir all
>> >> >
>> >> > This gives a target 'examples' in the top-level Makefile, which is
>> not
>> >> > included in 'all', but can be used to build all examples. I would
>> like
>> >> > to
>> >> > achieve something similar with CMake.
>> >> >
>> >> > I added example_dir/CMakeLists.txt, which includes a project()
>> command
>> >> > and
>> >> > defines all the targets for example executables. In the toplevel
>> >> > CMakeList,
>> >> > I did this:
>> >> >
>> >> > # Add the subdirectory but don't include its targets by default
>> >> > add_subdirectory(example_dir EXCLUDE_FROM_ALL)
>> >> >
>> >> > # Add a custom target to build all examples
>> >> > add_custom_target(examples ???)
>> >> >
>> >> > I'm stuck at the custom target. What I need for its command is a
>> >> > generator-agnostic equivalent for 'make -C example_dir all' (or
>> 'make -f
>> >> > example_dir/Makefile all').
>> >> >
>> >> > I tried 'cmake --build ${CMAKE_CURRENT_BINARY_DIR}/example_dir ...',
>> but
>> >> > this complains that example_dir does not contain a CMakeCache.txt
>> (which
>> >> > is
>> >> > correct of course, it's not the toplevel directory). Then I
>> remembered
>> >> > that
>> >> > build_command() can be used to get a command line to build a project;
>> >> > unfortunately, in 3.0 and later, this just returns 'cmake --build
>> ...'
>> >> > and
>> >> > so is unusable in my situation.
>> >> >
>> >> > Is there a way to query CMake for the native command line (or
>> something
>> >> > else) I could use to build the CMake-generated buildsystem in the
>> >> > subdirectory? I thought a bit about CMAKE_MAKE_PROGRAM, but that
>> doesn't
>> >> > tell me anything about what arguments I should pass

Re: [CMake] project directive overwrites CMAKE_INSTALL_PREFIX?

2014-12-05 Thread Chris Johnson
This looks like a bug to me.  I have a very simple test case where
CMAKE_INSTALL_PREFIX is set correctly if I do so after the project()
statement, and fails to be set correctly if I do it before the project()
statement.

On Fri, Dec 5, 2014 at 2:06 PM, Chris Johnson  wrote:

> Strangely, running "cmake -DCMAKE_INSTALL_PREFIX=/some/path" does NOT
> rewrite the cmake_install.cmake, but does rewrite the CMakeCache.txt and
> other files.  The result is a bad install path won't go away until one
> manually removes the cmake_install.cmake file(s).
>
> On Thu, Dec 4, 2014 at 9:48 PM, J Decker  wrote:
>
>> I find it's better to define CMAKE_INSTALL_PREFIX on the command line
>> when building
>>
>> I do have this bit of code...
>>
>> IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
>>   SET(CMAKE_INSTALL_PREFIX
>> ${CMAKE_BINARY_DIR}/../${CMAKE_BUILD_TYPE}_out CACHE PATH "Install
>> default 'out' in this directory." FORCE
>> )
>> ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
>>
>>
>> which keeps it from overwriting an already set value (from the command
>> line); and make sure it's in the cache so cmake-gui can edit it...
>>
>> (if  project() does something with cmake_isnstall_prefix might also be a
>> bug)
>>
>> On Thu, Dec 4, 2014 at 7:27 PM, Chris Johnson 
>> wrote:
>>
>>> I have a global include file used by all of the CMakeLists.txt files in
>>> my project. In it, I set the value of CMAKE_INSTALL_PREFIX, as well as a
>>> number of other variables and functions.
>>>
>>> In my CMakeLists.txt file, I had this:
>>>
>>> cmake_minimum_require(VERSION 2.8.4)
>>> include(global.inc)
>>> project(whatever)
>>>
>>> When I run cmake, the value of CMAKE_INSTALL_PREFIX is lost! Instead, in
>>> the resulting cmake_install.cmake file has been defaulted back to
>>> /usr/local which is completely wrong.
>>>
>>> However, if I change the order to this:
>>>
>>> cmake_minimum_require(VERSION 2.8.4)
>>> project(whatever)
>>> include(global.inc)
>>>
>>> It appears to work.
>>>
>>> I find nothing in the documentation saying that the project() directive
>>> will set CMAKE_INSTALL_PREFIX.
>>>
>>> Even more strangely, if I run cmake a second time with the first
>>> configuration (include before project), it will rewrite cmake_install.cmake
>>> with the correct value.
>>> ​ ​
>>> That is, the behavior of cmake appears to be different based on whether
>>> the build directory is empty or already contains cmake_install.cmake and
>>> CMakeCache.txt files
>>> ​, even though they contain the wrong path value for
>>> CMAKE_INSTALL_PREFIX.​
>>>
>>> What is going on here?
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>> 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
>>>
>>
>>
>
-- 

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