<div dir="ltr"><div>Hi,<br><br>Am new to this mailing list. And have looked at CMake as a tool in a number of other projects including LLVM, but still consider myself a CMake newbie.<br><br>I am looking at using CMake for a group of meta language based projects I am developing.<br><br>Basically I need to be able to develop for all three major C++ compilers, MSVC, GCC, and Clang, on all major platforms, Windows, Linux and on the Mac.<br><br>What I am wondering is if there is a good starting point / set of scripts for CMake that will allow me to build :-<br><br>   a) On Windows for MSVC, Clang and GCC<br>   b) For Linux with Clang/LLVm tool chain and GCC<br><br>And at some point<br>   c) XCode on the Mac<br><br>Support for using Googles gtest.<br><br>Basically I don't want to get too bogged down with CMake scripts if it is possible to avoid getting bogged down with them as much as it is possible.<br><br>Heres where I am now, I have pinched gtests script and have Windows MSVC, MSYS GCC and Linux GCC and Clang.<br><br>I have used gtest's script as a staring place :-<br><br>    <a href="https://github.com/google/googletest/blob/master/googletest/cmake/internal_utils.cmake">https://github.com/google/googletest/blob/master/googletest/cmake/internal_utils.cmake</a></div><div><br></div><div>And the following script :-<br>~~~<br>cmake_minimum_required(VERSION 2.6)<br>set(CMAKE_AR /usr/bin/ar CACHE FILEPATH "Archiver")</div><div><br></div><div>project(gtest-test CXX C)</div><div><br></div><div>find_package (Threads)</div><div><br></div><div># Define helper functions and macros.<br>include(cmake/internal_utils.cmake)<br>config_compiler_and_linker()  # Defined in internal_utils.cmake.</div><div><br></div><div>#message("prefix: ${CMAKE_FIND_LIBRARY_PREFIXES}")<br>#message("suffix: ${CMAKE_FIND_LIBRARY_SUFFIXES}")</div><div><br></div><div>find_package(BISON)<br>find_package(FLEX)</div><div><br></div><div><br># Locate GTest<br>find_package(GTest REQUIRED)<br>include_directories(${GTEST_INCLUDE_DIRS})</div><div><br></div><div># Link runTests with what we want to test and the GTest and pthread library<br>add_executable(runTests tests.cpp)<br>target_link_libraries(runTests ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})<br>~~~</div><div><br></div><div>It runs fine on Windows with MSVC, seems to be failing on MSYS :-</div><div>~~~</div><div><p>$ cmake -G "MSYS Makefiles" .<br>CMake Error: CMAKE_AR was not found, please set to archive program.<br>CMake Error: CMAKE_AR was not found, please set to archive program.<br>CMake Error: CMAKE_AR was not found, please set to archive program.<br>CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:148 (message):<br>Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)<br><br>Call Stack (most recent call first):<br>C:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)<br>C:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindGTest.cmake:204 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)<br><br>CMakeLists.txt:20 (find_package)<br><br>-- Configuring incomplete, errors occurred!<br>See also "C:/Users/Aaron/GitHub/GTest/CMakeFiles/CMakeOutput.log".<br>See also "C:/Users/Aaron/GitHub/GTest/CMakeFiles/CMakeError.log".</p><p><b></b><i></i><u></u><sub></sub><sup></sup><strike></strike>~~~</p><p>CMakeOutput.txt and CMakeError.txt Files attached.</p><p>So if theres either a better starting point or better/proper way of doing this then please put me on the right path.</p><p>Aaron</p><p><br></p></div></div>