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?

1
  • 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. Commented Apr 9, 2013 at 16:57

2 Answers 2

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>
Sign up to request clarification or add additional context in comments.

1 Comment

This leads to the error "could not find compiler set in environment variable CC"...
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}")

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.