Creating a project using CMake, including other libraries that use different build systems

I am working on an open source project that uses C for libraries, C++ for the GUI, and Cmake for managing the assembly. This project has just begun and has only a couple of files. I can successfully generate makefiles in my Linux development environment, and on Windows I can generate Visual Studio project files using CMake. So far, everything is working well.

As the project develops, I am at a stage where I need a testing platform. I have good experience with UnitTest++ , which will work well on all popular platforms.

The problem is that I don’t know how to integrate the UnitTest++ construct with Cmake (they use makefile in linux and visual studio files for windows). I need to compile UnitTest++ files to create a library before creating my code. How can I specify this in CMake in a way that will work with linux and windows?

+4
source share
1 answer

I am using this CMakeLists.txt:

 #/**********************************************************\ #Original Author: Richard Bateman (taxilian) # #Created: Nov 20, 2009 #License: Dual license model; choose one of two: # New BSD License # http://www.opensource.org/licenses/bsd-license.php # - or - # GNU Lesser General Public License, version 2.1 # http://www.gnu.org/licenses/lgpl-2.1.html # #Copyright 2009 PacketPass, Inc and the Firebreath development team #\**********************************************************/ cmake_minimum_required (VERSION 2.8) project (UnitTest++) message ("Generating project ${PROJECT_NAME}") include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) list (APPEND SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AssertException.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Checks.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/TestRunner.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/TestResults.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/TestReporter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/TestReporterStdout.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/ReportAssert.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/TestList.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/TimeConstraint.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/TestDetails.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/MemoryOutStream.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/DeferredTestReporter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/DeferredTestResult.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/XmlTestReporter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/CurrentTest.cpp ) if (UNIX) list(APPEND SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/Posix/SignalTranslator.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Posix/TimeHelpers.cpp ) elseif (WIN32) list(APPEND SOURCES src/Win32/TimeHelpers.cpp ) endif() add_library (UnitTest++ STATIC ${SOURCES}) add_definitions( -D_CRT_SECURE_NO_DEPRECATE ) if (UNIX) set_target_properties(UnitTest++ PROPERTIES COMPILE_FLAGS "-g -Wall -W -ansi" ) endif(UNIX) 
+4
source

Source: https://habr.com/ru/post/1313882/


All Articles