cmake

Optional Argument in cmake macro

I want to create a macro whose argument is optional. If not specified, the argument's value should be an empty string. How can I do this? Thanks for your help. ...

cmake settings on snow leopard

I am trying to compile my project on Snow Leopard using the same CMakeLists.txt file that I had on Leopard, however the compilation fails with the following error message: Linking C executable cmTryCompileExec "/Applications/CMake 2.6-4.app/Contents/bin/cmake" -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbo...

How to set an Xcode attribute in CMake for a specific configuration?

I'm using CMake to generate an Xcode project, and I use set_target_properties(myproj PROPERTIES XCODE_ATTRIBUTE_WHATEVER "some value") to explicitly set a build setting. I'd like to only set it for a particular configuration, similar to using set(CMAKE_CXX_FLAGS_MYCONFIG "-O2") How can I do this? ...

CMake variable or property to discern betwen debug and release builds

I want to set a CMake variable differently for debug and release builds. I have tried to use CMAKE_CFG_INTDIR like this: IF(${CMAKE_CFG_INTDIR} STREQUAL "Debug") SET(TESTRUNNER DllPlugInTesterd_dll) ELSE(${CMAKE_CFG_INTDIR} STREQUAL "Debug") SET(TESTRUNNER DllPlugInTester_dll) ENDIF(${CMAKE_CFG_INTDIR} STREQUAL "Debug") But th...

How to build object files only once with cmake?

I have a CMakeLists.txt file that looks like this: add_executable(exec1 exec1.c source1.c source2.c source3.c) add_executable(exec2 exec2.c source1.c source2.c source3.c) add_executable(exec3 exec3.c source1.c source2.c source3.c) The source1.o source2.o source3.o files take a really long time to build, and since they are common to al...

How can I pass git SHA1 to compiler as definition using cmake?

In a Makefile this would be done with something like: g++ -DGIT_SHA1="`git log -1 | head -n 1`" ... This is very useful, because the binary knows exact commit SHA1 so it can dump it in case of segfault. How can I achieve the same with CMake? ...

How to run a command at compile with in Makefile generated by CMake ?

I would like to pass some options to a compiler. The option would have to be calculated at compile time - everytime when 'make' is invoked, not when 'cmake', so execute_process command does not cut it. (does it?) For instance passing a date to a g++ compiler like that: g++ prog.cpp -o prog -DDATETIME="17:09:2009,14:25" But with DATET...

Cross-platform developement?

I am looking for a solution which would allow me to code for Linux and Windows using C++. On Windows I use Visual Studio (I tried other stuff on Windows but I work with DirectX and as far as I know, it's the best solution). On Linux I use NetBeans (which I like very much). My problem is that I want the project be independent of Visual...

How to include directories in cmake generated visual studio projects?

I have (roughly) the following CMakeLists.txt project(Test) set(SOURCE 123.cpp 456.cpp ) find_package(Boost COMPONENTS unit_test_framework REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) message("${Boost_INCLUDE_DIRS}") add_executable(Tests ${SOURCE}) The message generated by message...

Embedding one cmake project inside of another?

I have two projects, both of which use CMake. Now I want to include one of the projects as a library inside the other, while still maintaining the ability to compile them as standalone projects. What I have done so far is: Use the version control system to clone a copy of the child project in a subdir of the parent project. I've used th...

How to Use CMake for Non-Interactive Build on Windows?

I want to set up automated build using CMake on Windows. I am using Visual Studio 2005. Update: Here is what I am using: I set devenv.exe to my PATH. Then to build I run the command below. I am using Hudson to build. devenv Crackpot.sln /build Debug /project ALL_BUILD As per http://blogs.msdn.com/aaronhallberg/archive/2007/06/29/buil...

How do I enable the SSE/SSE2 instruction set in Visual Studio 2008 (using CMake)?

In Visual Studio 2005 I went in: View --> Property Pages --> C/C++ --> Code Generation --> Enable Enhanced Instruction Set But in Visual Studio 2008? Thanks in advance ...

Third party libraries in CMake

I am using cmake for my project, but I have another library in a subdirectory ( say lib/ ) which uses a plain Makefile. How do I instruct CMake to run the Makefile in lib as part of the build process? ...

How do I instruct CMake to look for libraries installed by MacPorts?

I'm trying to build some of our software, which was designed to run solely on Linux, on MacOS X. We are using CMake and I installed MacPorts so I could easily get CMake along with some of the third party libraries that we depend on. Now the problem is that CMake doesn't appear to look for libraries from MacPorts by default so several of...

Generating SWIG bindings with CMake

How would I generate automatic bindings for a C project that is built using CMake? I want to generate bindings for Python, Java, .NET, PHP, Perl, TCL, Ruby and Octave automatically. ...

How to abort processing CMakeLists for current directory

I have a project structure like: src/CMakeLists.txt src/test/component1/CMakeLists.txt src/test/component2/CMakeLists.txt For the testing, I'm using Qt - however, I want to make sure that if Qt (or some other test-specific package is not found) I simply skip the package. I tried find_package(Qt4 QUIET COMPONENTS QtCore QtTestLib) if...

What is different about the CMake command configure_file on Windows?

On linux I am using a command such as: configure_file(dot_alpha_16.bmp test/dot_samples/dot_alpha_16.bmp COPYONLY) to copy some unit test files to the build directory. On windows the files aren't getting copied. Is there a specific reason why this happens? ...

Using SWIG with a build system

Anyone have experience with using SWIG (the interface generator)? I have a C project which I would like to expose to a bunch of other languages/frameworks, like Python, Java, .NET, Perl, PHP, Ruby. I would like to integrate with my build system (which is CMake-based), but any method of accomplishing this will do. ...

cmake and eclipse: default include paths?

Hello! I have a project that builds with CMake system, and I like to import it in Eclipse. However, when I generate eclipse project files with 'cmake -G "Eclipse CDT4 - Unix Makefiles"' there are no default include paths in Eclipse project(such as /usr/include' or the gcc path for standard headers). How to fix that in most right way? ...

CMake output name for dynamic-loaded library?

Hello! I'm trying to write cmake rules to build dynamic-loaded library for python using boost.python on linux. I'd like to use 'foo' for python module name. So, the library must be called foo.so. But by default, cmake uses standard rules for library naming, so if I write add_library(foo foo.cpp) I will get libfoo.so on output. Even s...