Hi all, 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.
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: fltk-config --cxx I'd like to use the output of these queries to set the CMAKE_CXX_COMPILER and CMAKE_C_COMPILER variables. Here's what I have so far: find_program(FLTKCONFIG fltk-config) if(NOT FLTKCONFIG) message(FATAL_ERROR "Cannot find the fltk-config executable. Is FLTK installed?") endif(NOT FLTKCONFIG) execute_process(COMMAND ${FLTKCONFIG} --cxx OUTPUT_VARIABLE FLTK_CXX_COMPILER_QUERY_RESULT) execute_process(COMMAND ${FLTKCONFIG} --cc OUTPUT_VARIABLE FLTK_C_COMPILER_QUERY_RESULT) message(STATUS "Using C compiler (fltk-config -cc): ${FLTK_C_COMPILER_QUERY_RESULT}") message(STATUS "Using C++ compiler (fltk-config --cxx): ${FLTK_CXX_COMPILER_QUERY_RESULT}") find_program(CXX_COMPILER "${FLTK_CXX_COMPILER_QUERY_RESULT}") find_program(C_COMPILER "${FLTK_C_COMPILER_QUERY_RESULT}") message(STATUS "${CXX_COMPILER}") message(STATUS "${C_COMPILER}") set(CMAKE_CXX_COMPILER "${CXX_COMPILER}") set(CMAKE_C_COMPILR "${C_COMPILER}") And running this outputs: -- Using C compiler (fltk-config -cc): gcc -- Using C++ compiler (fltk-config --cxx): g++ -- CXX_COMPILER-NOTFOUND -- C_COMPILER-NOTFOUND -- /usr/local/bin/fltk-config ... Thanks! -deech
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake