[CMake] General cross platform stating place
Aaron Gray
aaronngray.lists at gmail.com
Mon Sep 7 18:47:35 EDT 2015
Hi,
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.
I am looking at using CMake for a group of meta language based projects I
am developing.
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.
What I am wondering is if there is a good starting point / set of scripts
for CMake that will allow me to build :-
a) On Windows for MSVC, Clang and GCC
b) For Linux with Clang/LLVm tool chain and GCC
And at some point
c) XCode on the Mac
Support for using Googles gtest.
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.
Heres where I am now, I have pinched gtests script and have Windows MSVC,
MSYS GCC and Linux GCC and Clang.
I have used gtest's script as a staring place :-
https://github.com/google/googletest/blob/master/googletest/cmake/internal_utils.cmake
And the following script :-
~~~
cmake_minimum_required(VERSION 2.6)
set(CMAKE_AR /usr/bin/ar CACHE FILEPATH "Archiver")
project(gtest-test CXX C)
find_package (Threads)
# Define helper functions and macros.
include(cmake/internal_utils.cmake)
config_compiler_and_linker() # Defined in internal_utils.cmake.
#message("prefix: ${CMAKE_FIND_LIBRARY_PREFIXES}")
#message("suffix: ${CMAKE_FIND_LIBRARY_SUFFIXES}")
find_package(BISON)
find_package(FLEX)
# Locate GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
# Link runTests with what we want to test and the GTest and pthread library
add_executable(runTests tests.cpp)
target_link_libraries(runTests ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
~~~
It runs fine on Windows with MSVC, seems to be failing on MSYS :-
~~~
$ cmake -G "MSYS Makefiles" .
CMake Error: CMAKE_AR was not found, please set to archive program.
CMake Error: CMAKE_AR was not found, please set to archive program.
CMake Error: CMAKE_AR was not found, please set to archive program.
CMake Error at C:/Program Files
(x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:148
(message):
Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR
GTEST_MAIN_LIBRARY)
Call Stack (most recent call first):
C:/Program Files
(x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:388
(_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindGTest.cmake:204
(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:20 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Aaron/GitHub/GTest/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Aaron/GitHub/GTest/CMakeFiles/CMakeError.log".
~~~
CMakeOutput.txt and CMakeError.txt Files attached.
So if theres either a better starting point or better/proper way of doing
this then please put me on the right path.
Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150907/b6ef9ac8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CMakeError.log
Type: application/octet-stream
Size: 5167 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150907/b6ef9ac8/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CMakeOutput.log
Type: application/octet-stream
Size: 30642 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150907/b6ef9ac8/attachment-0003.obj>
More information about the CMake
mailing list