> mkdir build > cd build > cmake -G "Unix Makefiles" .. -- The C compiler identification is GNU 4.2.1 -- The CXX compiler identification is GNU 4.2.1 -- Checking whether C compiler has -isysroot -- Checking whether C compiler has -isysroot - yes -- Checking whether C compiler supports OSX deployment target flag -- Checking whether C compiler supports OSX deployment target flag - yes -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Checking whether CXX compiler has -isysroot -- Checking whether CXX compiler has -isysroot - yes -- Checking whether CXX compiler supports OSX deployment target flag -- Checking whether CXX compiler supports OSX deployment target flag - yes -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /Volumes/Documents/Programming/C++/CMake Tutorial/flavors/part1_step1/build > ls CMakeCache.txt Makefile CMakeFiles cmake_install.cmake > make Scanning dependencies of target toDo [ 50%] Building CXX object CMakeFiles/toDo.dir/main.cc.o [100%] Building CXX object CMakeFiles/toDo.dir/ToDo.cc.o Linking CXX executable toDo [100%] Built target toDo
result |= EXPECT_EQUAL(list.size(), 3); result |= EXPECT_EQUAL(list.getTask(0), "write code"); result |= EXPECT_EQUAL(list.getTask(1), "compile"); result |= EXPECT_EQUAL(list.getTask(2), "test");
> mkdir build >cd build > cmake -G "Unix Makefiles" .. -- The C compiler identification is GNU 4.2.1 -- The CXX compiler identification is GNU 4.2.1 -- Checking whether C compiler has -isysroot -- Checking whether C compiler has -isysroot - yes -- Checking whether C compiler supports OSX deployment target flag -- Checking whether C compiler supports OSX deployment target flag - yes -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Checking whether CXX compiler has -isysroot -- Checking whether CXX compiler has -isysroot - yes -- Checking whether CXX compiler supports OSX deployment target flag -- Checking whether CXX compiler supports OSX deployment target flag - yes -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /Volumes/Documents/Programming/C++/CMake Tutorial/flavors/part1_step2/build > make Scanning dependencies of target toDo [ 50%] Building CXX object CMakeFiles/toDo.dir/main.cc.o [100%] Building CXX object CMakeFiles/toDo.dir/ToDo.cc.o Linking CXX executable toDo [100%] Built target toDo > make test Running tests... Test project /Volumes/Documents/Programming/C++/CMake Tutorial/flavors/part1_step2/build Start 1: toDoTest 1/1 Test #1: toDoTest ......................... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.03 sec > ls Testing Temporary > ls Testing/Temporary CTestCostData.txt LastTest.log > cat Testing/Temporary/LastTest.log Start testing: Jul 16 22:00 EDT ---------------------------------------------------------- 1/1 Testing: toDoTest 1/1 Test: toDoTest Command: "/Volumes/Documents/Programming/C++/CMake Tutorial/flavors/part1_step2/build/toDo" Directory: /Volumes/Documents/Programming/C++/CMake Tutorial/flavors/part1_step2/build "toDoTest" start time: Jul 16 22:00 EDT Output: ---------------------------------------------------------- Test passed <end of output> Test time = 0.01 sec ---------------------------------------------------------- Test Passed. "toDoTest" end time: Jul 16 22:00 EDT "toDoTest" time elapsed: 00:00:00 ---------------------------------------------------------- End testing: Jul 16 22:00 EDT > cat Testing/Temporary/CTestCostData.txt toDoTest 1 0.00976491 ---
make test: 因为向CMakelists.txt中添加了enable_testing()方法,这样Makefile里有“test”这个target,这个target会运行CTest来运行所以的测试用例,这里只有一个。
ZMAP的CMakelists.txt阅读
1 2 3 4 5 6 7 8 9 10 11
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(ZMAP C) set(ZMAP_VERSION DEVELOPMENT) # Change DEVELOPMENT to version number for release
option(WITH_REDIS "Build with support for Redis DB"OFF) option(ENABLE_DEVELOPMENT "Enable development specific compiler and linker flags"OFF) option(ENABLE_LOG_TRACE "Enable log trace messages"OFF) option(RESPECT_INSTALL_PREFIX_CONFIG "Respect CMAKE_INSTALL_PREFIX for /etc"OFF) option(WITH_WERROR "Build with -Werror"OFF) option(WITH_PFRING "Build with PF_RING ZC for send (10 GigE)"OFF) option(FORCE_CONF_INSTALL "Overwrites existing configuration files at install"OFF)
set(CPACK_PACKAGE_DESCRIPTION "Internet-scale network scanner") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ZMap is an open source network scanner that enables researchers to easily perform Internet-wide network studies. With a single machine and a well provisioned network uplink, ZMap is capable of performing a complete scan of the IPv4 address space in under five minutes, approaching the theoretical limit of gigabit Ethernet. ZMap can be used to study protocol adoption over time, monitor service availability, and help us better understand large systems distributed across the Internet.") set(CPACK_PACKAGE_CONTACT "Zakir Durumeric <zakird@gmail.com>") set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${VERSION}_${CPACK_DEBIAN_ARCHITECTURE}")