<div dir="ltr"><div><div><div><div><div>Hi all,<br>I'm using CMake to try compile a set of C bindings to the FLTK GUI library and would like to set the C/C++ compiler variables in the build script but haven't been successful. I realize that setting environment variables is the recommended method but I've tried to explain why I need it below.<br>
<br>The FLTK library also builds an executable called `fltk-config` that can be queried for information about the FLTK build. For examples, to find out what C++ compiler was used to build FLTK I can just do:<br></div>fltk-config --cxx<br>
<br></div>I'd like to use the output of these queries to set the CMAKE_CXX_COMPILER and CMAKE_C_COMPILER variables. <br><br></div>Here's what I have so far:<br>find_program(FLTKCONFIG fltk-config)<br>if(NOT FLTKCONFIG)<br>
message(FATAL_ERROR "Cannot find the fltk-config executable. Is FLTK installed?")<br>endif(NOT FLTKCONFIG)<br>execute_process(COMMAND ${FLTKCONFIG} --cxx OUTPUT_VARIABLE FLTK_CXX_COMPILER_QUERY_RESULT)<br>execute_process(COMMAND ${FLTKCONFIG} --cc OUTPUT_VARIABLE FLTK_C_COMPILER_QUERY_RESULT)<br>
message(STATUS "Using C compiler (fltk-config -cc): ${FLTK_C_COMPILER_QUERY_RESULT}")<br>message(STATUS "Using C++ compiler (fltk-config --cxx): ${FLTK_CXX_COMPILER_QUERY_RESULT}")<br>find_program(CXX_COMPILER "${FLTK_CXX_COMPILER_QUERY_RESULT}")<br>
find_program(C_COMPILER "${FLTK_C_COMPILER_QUERY_RESULT}")<br>message(STATUS "${CXX_COMPILER}")<br>message(STATUS "${C_COMPILER}")<br>set(CMAKE_CXX_COMPILER "${CXX_COMPILER}")<br>set(CMAKE_C_COMPILR "${C_COMPILER}")<br>
<br></div>And running this outputs:<br>-- Using C compiler (fltk-config -cc): gcc<br><br>-- Using C++ compiler (fltk-config --cxx): g++<br><br>-- CXX_COMPILER-NOTFOUND<br>-- C_COMPILER-NOTFOUND<br>-- /usr/local/bin/fltk-config<br>
...<br><br></div>Thanks!<br>-deech<br></div>