diff options
Diffstat (limited to '')
-rw-r--r-- | CMakeLists.txt | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..2f0e768a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,99 @@ +cmake_minimum_required (VERSION 2.6) +project (usdx-cpp) + +set(cflags "-Wall -Werror -pedantic") +set(cxxflags "${cflags} -std=c++1y") +set(debug "-g -O0") + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cflags}") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${debug}") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxxflags}") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${debug}") + +# +# dependency handling +# +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") +set(Boost_USE_MULTITHREADED "ON") + +include("Require") +require(FTGL) +require(Freetype) +require(SDL) +require(SDL_image) +require(SDL_gfx) +require(log4cpp) +require(Boost COMPONENTS filesystem locale program_options system thread) +require(OpenGL) + +# +# get main sources +# +include_directories(src/) +file(GLOB_RECURSE sources src/*.cpp) +list(REMOVE_ITEM sources "${CMAKE_SOURCE_DIR}/src/main.cpp") +add_library(objects OBJECT ${sources}) + +# +# main usdx binary +# +add_executable(usdx "src/main.cpp" $<TARGET_OBJECTS:objects>) +target_link_libraries(usdx ${LIBS}) + +# +# make run +# +add_custom_target(run + COMMAND usdx + DEPENDS usdx + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +) + +# +# tests +# +include(CTest) + +if(BUILD_TESTING) + require_test(CppUnit) + + file(GLOB_RECURSE testing_sources test/*.cpp) + add_executable(test/usdx-test ${testing_sources} $<TARGET_OBJECTS:objects>) + target_link_libraries(test/usdx-test ${LIBS} ${TEST_LIBS}) + add_test(NAME test + COMMAND test/test + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/test/" + ) +endif() + +# +# tests with coverage +# +set(coverage-dir "${PROJECT_SOURCE_DIR}/test/coverage") + +add_executable(test/usdx-test-coverage EXCLUDE_FROM_ALL + ${testing_sources} ${sources}) +target_link_libraries(test/usdx-test-coverage ${LIBS} ${TEST_LIBS} "-coverage") +set_target_properties(test/usdx-test-coverage + PROPERTIES COMPILE_FLAGS "${debug} -fprofile-arcs -ftest-coverage") + +get_property(coverage-binary TARGET test/usdx-test-coverage PROPERTY LOCATION) +add_custom_target(test-coverage WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/test/" + # prepare coverage checks + COMMAND rm -f .error + COMMAND mkdir -p "${coverage-dir}" + COMMAND lcov --directory "${PROJECT_SOURCE_DIR}" --zerocounters + + # running checks and save result for later use + COMMAND sh -c \"${coverage-binary} || touch .error\" + + # building coverage pages + COMMAND lcov --directory "${PROJECT_SOURCE_DIR}" --capture --output-file "${coverage-dir}/coverage.info.tmp" + COMMAND lcov --extract "${coverage-dir}/coverage.info.tmp" "'${PROJECT_SOURCE_DIR}/src/*'" -o "${coverage-dir}/coverage.info" + COMMAND genhtml "${coverage-dir}/coverage.info" -o "${coverage-dir}/html/" -p "${PROJECT_SOURCE_DIR}/src" + + # returing check status + COMMAND test ! -e .error +) +add_dependencies(test-coverage test/usdx-test-coverage) |