[CMake] How to choose a compiler different from default?

Peng Yu pengyu.ut at gmail.com
Sun Jun 7 18:39:39 EDT 2015


Hi, I following the following steps to compile gtest.

https://code.google.com/p/tonatiuh/wiki/GoogleTest

But the following output shows that it uses the default compiler on
Mac OS X. I want to use some other compiler. Does anybody know how to
instruct cmake to do so? Thanks.

/tmp/gtest-1.7.0/mybuild$ cmake -G"Unix Makefiles" ..
-- The CXX compiler identification is AppleClang 6.0.0.6000057
-- The C compiler identification is AppleClang 6.0.0.6000057
-- Check for working CXX compiler:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PythonInterp:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python (found
version "2.7.8")
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/gtest-1.7.0/mybuild
/tmp/gtest-1.7.0/mybuild$ make VERBOSE=1
/usr/local/Cellar/cmake/3.2.2/bin/cmake -H/tmp/gtest-1.7.0
-B/tmp/gtest-1.7.0/mybuild --check-build-system
CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.2.2/bin/cmake -E cmake_progress_start
/tmp/gtest-1.7.0/mybuild/CMakeFiles
/tmp/gtest-1.7.0/mybuild/CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f
CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f
CMakeFiles/gtest.dir/build.make CMakeFiles/gtest.dir/depend
cd /tmp/gtest-1.7.0/mybuild && /usr/local/Cellar/cmake/3.2.2/bin/cmake
-E cmake_depends "Unix Makefiles" /tmp/gtest-1.7.0 /tmp/gtest-1.7.0
/tmp/gtest-1.7.0/mybuild /tmp/gtest-1.7.0/mybuild
/tmp/gtest-1.7.0/mybuild/CMakeFiles/gtest.dir/DependInfo.cmake
--color=
Dependee "/tmp/gtest-1.7.0/mybuild/CMakeFiles/gtest.dir/DependInfo.cmake"
is newer than depender
"/tmp/gtest-1.7.0/mybuild/CMakeFiles/gtest.dir/depend.internal".
Dependee "/tmp/gtest-1.7.0/mybuild/CMakeFiles/CMakeDirectoryInformation.cmake"
is newer than depender
"/tmp/gtest-1.7.0/mybuild/CMakeFiles/gtest.dir/depend.internal".
Scanning dependencies of target gtest
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f
CMakeFiles/gtest.dir/build.make CMakeFiles/gtest.dir/build
/usr/local/Cellar/cmake/3.2.2/bin/cmake -E cmake_progress_report
/tmp/gtest-1.7.0/mybuild/CMakeFiles 1
[ 50%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
   -I/tmp/gtest-1.7.0/include -I/tmp/gtest-1.7.0
-DGTEST_HAS_PTHREAD=1   -o CMakeFiles/gtest.dir/src/gtest-all.cc.o -c
/tmp/gtest-1.7.0/src/gtest-all.cc
Linking CXX static library libgtest.a
/usr/local/Cellar/cmake/3.2.2/bin/cmake -P
CMakeFiles/gtest.dir/cmake_clean_target.cmake
/usr/local/Cellar/cmake/3.2.2/bin/cmake -E cmake_link_script
CMakeFiles/gtest.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
cq libgtest.a  CMakeFiles/gtest.dir/src/gtest-all.cc.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
libgtest.a
/usr/local/Cellar/cmake/3.2.2/bin/cmake -E cmake_progress_report
/tmp/gtest-1.7.0/mybuild/CMakeFiles  1
[ 50%] Built target gtest
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f
CMakeFiles/gtest_main.dir/build.make CMakeFiles/gtest_main.dir/depend
cd /tmp/gtest-1.7.0/mybuild && /usr/local/Cellar/cmake/3.2.2/bin/cmake
-E cmake_depends "Unix Makefiles" /tmp/gtest-1.7.0 /tmp/gtest-1.7.0
/tmp/gtest-1.7.0/mybuild /tmp/gtest-1.7.0/mybuild
/tmp/gtest-1.7.0/mybuild/CMakeFiles/gtest_main.dir/DependInfo.cmake
--color=
Dependee "/tmp/gtest-1.7.0/mybuild/CMakeFiles/gtest_main.dir/DependInfo.cmake"
is newer than depender
"/tmp/gtest-1.7.0/mybuild/CMakeFiles/gtest_main.dir/depend.internal".
Dependee "/tmp/gtest-1.7.0/mybuild/CMakeFiles/CMakeDirectoryInformation.cmake"
is newer than depender
"/tmp/gtest-1.7.0/mybuild/CMakeFiles/gtest_main.dir/depend.internal".
Scanning dependencies of target gtest_main
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f
CMakeFiles/gtest_main.dir/build.make CMakeFiles/gtest_main.dir/build
/usr/local/Cellar/cmake/3.2.2/bin/cmake -E cmake_progress_report
/tmp/gtest-1.7.0/mybuild/CMakeFiles 2
[100%] Building CXX object CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
   -I/tmp/gtest-1.7.0/include -I/tmp/gtest-1.7.0
-DGTEST_HAS_PTHREAD=1   -o
CMakeFiles/gtest_main.dir/src/gtest_main.cc.o -c
/tmp/gtest-1.7.0/src/gtest_main.cc
Linking CXX static library libgtest_main.a
/usr/local/Cellar/cmake/3.2.2/bin/cmake -P
CMakeFiles/gtest_main.dir/cmake_clean_target.cmake
/usr/local/Cellar/cmake/3.2.2/bin/cmake -E cmake_link_script
CMakeFiles/gtest_main.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
cq libgtest_main.a  CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
libgtest_main.a
/usr/local/Cellar/cmake/3.2.2/bin/cmake -E cmake_progress_report
/tmp/gtest-1.7.0/mybuild/CMakeFiles  2
[100%] Built target gtest_main
/usr/local/Cellar/cmake/3.2.2/bin/cmake -E cmake_progress_start
/tmp/gtest-1.7.0/mybuild/CMakeFiles 0

-- 
Regards,
Peng


More information about the CMake mailing list