2

I want to prefix the compiler with a utility script, so instead of for example g++-4.7 main.cpp,kinst-ompp g++-4.7 main.cpp is invoked.

I tried doing this in the CMakeLists.txt, but I'm getting a "not found" error:

set(CMAKE_CXX_COMPILER "${OMPP_CXX} ${CMAKE_CXX_COMPILER}")
set(CMAKE_C_COMPILER "${OMPP_CC} ${CMAKE_C_COMPILER}")

How do I properly configure this using CMake?

user1101674
  • 1,341
  • 2
  • 12
  • 15
  • If you're using the Makefile generator, Try running `VERBOSE=1 make` after running cmake. That way, you can see exactly which commands get invoked by make - maybe it helps debugging the issue. – lethal-guitar Apr 09 '13 at 16:57

2 Answers2

2

You should avoid setting the compiler in this way - see cmake: problems specifying the compiler (2) and this CMake FAQ entry for more info.

I think the following should work (after deleting your CMakeCache.txt):

export CC="kinst-ompp gcc-4.7" CXX="kinst-ompp g++-4.7" cmake <Path to CMakeLists.txt>
Community
  • 1
  • 1
Fraser
  • 74,704
  • 20
  • 238
  • 215
0

I got this to work by setting my compiler to the prefix and then passing the real compiler name as first argument. Ugly, I know.

set(CMAKE_CXX_COMPILER "${OMPP_CXX}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_COMPILER} ${commonCXXFlags} ${commonReleaseFlags}")
eli
  • 662
  • 8
  • 18
  • This works only if some CMAKE script is not prefixing CMAKE_CXX_FLAGS_RELEASE by something (e.g. preprocessor define.) If this happens you will get undecipherable errors during compilation. Fraser's answer below worked for me. – Sameer Jun 05 '15 at 21:40