Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake - How to avoid CMAKE_CXX_FLAGS in linker command-line

I'm having a problem with cmake / gcc / Linux.

No matter what I try, I cannot get rid of CMAKE_CXX_FLAGS on my linker line. CMake keeps passing them when invoking g++ in link mode.

I have -fopenmp in my CMAKE_CXX_FLAGS and it must not be present on the link line so g++ doesn't link to gomp (I'm using Intel's iomp5 instead).

Edit: I tried the following the beginning of CMakeLists.txt, didn't help:

set(CMAKE_CXX_LINK_EXECUTABLE
    "<CMAKE_CXX_COMPILER>  <FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET> <LINK_LIBRARIES>")

Thanks

like image 764
Alexander Avatar asked Nov 30 '17 19:11

Alexander


1 Answers

Turns out

add_compile_options("-fopenmp")

avoids adding these options to the linker. It doesn't solve the general issue of CMAKE_CXX_FLAGS showing up in the linker line, but it solves the immediate problem I have.

like image 187
Alexander Avatar answered Nov 03 '22 03:11

Alexander