View Full Version : Compiling errors and using Cmake Set Policy

01-23-2010, 03:57 PM
Compiling errors and using Cmake Set Policy



I'm new to the world of compiling in Linux and I thought this is the best place to ask questions!

I discovered the project I'm trying to compile has two add_executable targets that share the same name in two different folders. Both of these add_executable targets are in two separate CMakeList.txt files.

for example



When compiling in Ubuntu jaunty 9.04 with cmake 2.6, it has the new cmake_policy parameters to help programmers.

The --help-policy CMP0002 suggested I use the OUTPUT_NAME property but I get entirely new errors when trying the following"



ADD_EXECUTABLE(test_f1 test.cpp)


ADD_EXECUTABLE(test_f2 main.cpp)

Is there a better approach to eliminating the error or am I on the right path?
I'm open to any suggestions.

Below is the output from the cmake.



mdtom@ubuntu:~/icap/build$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- checking for module 'ImageMagick++'
-- found ImageMagick++, version 6.4.5
-- checking for module 'gtkmm-2.4>=2.10'
-- found gtkmm-2.4, version 2.16.0
-- checking for module 'cairomm-1.0'
-- found cairomm-1.0, version 1.6.4
-- checking for module 'gthread-2.0'
-- found gthread-2.0, version 2.20.1
CMake Warning (dev) at gui/CMakeLists.txt:12 (add_executable):
Policy CMP0002 is not set: Logical target names must be globally unique.
Run "cmake --help-policy CMP0002" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
CMake Warning (dev) at core/CMakeLists.txt:25 (add_executable):
Policy CMP0003 should be set before this line. Add code such as

if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

as early as possible but after the most recent call to
cmake_minimum_required or cmake_policy(VERSION). This warning appears
because target "test" links to some libraries for which the linker must

Magick++, MagickCore

and other libraries with known full path:


CMake is adding directories in the second list to the linker search path in
case they are needed to find libraries from the first list (for backwards
compatibility with CMake 2.4). Set policy CMP0003 to OLD or NEW to enable
or disable this behavior explicitly. Run "cmake --help-policy CMP0003" for
more information.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /home/mdtom/icap/build

01-23-2010, 11:35 PM
Never heard of it.

I might suggest you start at the source (http://www.cmake.org/) and work your way out through the various link paths until you find the answer.

There are 1000's of things which run on Linux, so don't pick a "Linux" forum to being with, start with the application you're running.

Also here
Compiling errors and using Cmake Set Policy - Linux Forums (http://www.linuxforums.org/forum/linux-programming-scripting/158983-compiling-errors-using-cmake-set-policy.html)

01-25-2010, 01:43 PM
Post your original CMakeLists.txt file. I have a script I wrote to auto-gen projects in CMake so if I need to do a fast "what-if" project I can cd to an empty folder, run this script, answer a small handful of questions and get a full CMake project, complete with skeletal C++ reflecting the answers to the questions that compiles and runs (without your errors); IOW a complete running project that I can start hanging code off of to do <whatever> in about 10 seconds. Let's see what your CMake stuff looks like...sounds like you are trying to use OUTPUT_NAME variable w/o treating it like one but I cannot be sure..