[CMake] set_target_properties to target openmp flag on an executable

Caner Candan caner at candan.fr
Tue Mar 22 04:24:59 EDT 2011


Perfect as ever. I just replaced the code by:

----------------------------------------------------------------------------------------------
PROJECT(test CXX)
ADD_EXECUTABLE(test test.cpp)
SET_TARGET_PROPERTIES(test PROPERTIES COMPILE_FLAGS "-fopenmp"
LINK_FLAGS "-fopenmp")
----------------------------------------------------------------------------------------------

and it works perfectly.

Thank you guys,
Caner Candan

On Fri, Mar 18, 2011 at 3:20 PM, Eric Noulard <eric.noulard at gmail.com> wrote:
> 2011/3/18 Caner Candan <caner at candan.fr>:
>> Hi all,
>>
>> Since I have several targets to compile, I was looking for a way to
>> set some specific flags to one target among all others. In my example
>> I would like to set the openmp flag to the target test and I got an
>> error with the code below:
>>
>> ----------------------------------------------------------------------------------------------
>> PROJECT(test CXX)
>> ADD_EXECUTABLE(test test.cpp)
>> SET_TARGET_PROPERTIES(test PROPERTIES COMPILE_FLAGS "-fopenmp")
>> ----------------------------------------------------------------------------------------------
>>
>> Error:
>> ----------------------------------------------------------------------------------------------
>> [100%] Building CXX object CMakeFiles/test.dir/test.cpp.o
>> Linking CXX executable test
>> CMakeFiles/test.dir/test.cpp.o: In function `main':
>> test.cpp:(.text+0x29): undefined reference to `GOMP_parallel_start'
>> test.cpp:(.text+0x3a): undefined reference to `GOMP_parallel_end'
>> collect2: ld returned 1 exit status
>> make[2]: *** [test] Error 1
>> make[1]: *** [CMakeFiles/test.dir/all] Error 2
>
> Don't you need the same flags for linking?
> see the "LINK_FLAGS" property.
>
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
>


More information about the CMake mailing list