11
這是我想做的事:大廈測試,而沒有使用CTEST
- 鍵入
make all
將建立我的圖書館,併爲它的文檔。 - 打字
make test
如果需要的話將建立我的lib(如有必要),GTEST然後我的測試 - 打字
make check
運行make test
,然後運行可執行
現在我只設法獲得第一上班。 我遇到的問題是gtest的條件包含。
Gtest使用的CMake很好,理論上我所需要做的就是包含gtest目錄和add_subdirectory
,但是gtest會一直建立。
我的結構,現在的問題是:
CMakeLists.txt (Here I add targets for doc and the library) doc (my doxygen docs) include (my headers) lib (where my compiled libraries go) src (where my .cpp files go) test CMakeLists.txt (Here I add targets for gest and my tests) bin (where the test executable will go) contrib (where gtest is) src (my tests)
我試圖找出如何添加GTEST作爲一個依賴於test
-target但每次不建GTEST。
我真的非常惱火,並且很少有關於學習CMake的信息,所以如果有人知道任何深入的教程(可以在互聯網上免費獲得),那將是非常棒的。
如果你知道這一點,你會有興趣幫我添加到C++庫項目模板(http://code.google.com/p/cpp-library-project-template/)嗎? (儘管發佈的版本使用unittest ++,但是目前使用gmock/gtest和glog,但它始終構建測試,並在運行「make」時執行測試)。 – 2011-04-10 04:06:47
當然,如果我想出來:) – 2011-04-10 04:19:26
哇,現在感覺有點愚蠢。訣竅是做'add_subdirectory(contrib/gtest EXCLUDE_FROM_ALL)'和'add_executable(測試EXCLUDE_FROM_ALL foo.cpp)'' – 2011-04-10 04:30:49