CMakeLists.txt 2.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
include (ACGCommon)

include_directories (
  ..
  ${CMAKE_CURRENT_SOURCE_DIR}
)

# Search for gtest headers and libraries
find_package(GoogleTest)

if(GTEST_FOUND)
   
    # Set correct include paths so that the compiler can find the headers
    include_directories(${GTEST_INCLUDE_DIRS})
    # set additional link directories
    link_directories(${GTEST_LIBRARY_DIR} )
17 18 19 20 21 22

 
    # Create executable for all unittests
    FILE(GLOB UNITTEST_SRC *.cc)
    add_executable(unittests ${UNITTEST_SRC})

23
	
24
    if ( NOT WIN32)
25 26 27 28 29 30 31 32 33 34 35 36 37 38
      # Link against all necessary libraries
      target_link_libraries(unittests OpenVolumeMesh ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
	  
	  # Set output directory to ${BINARY_DIR}/Unittests
      set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Unittests)
	
    else()
	  # Link against all necessary libraries
      target_link_libraries(unittests OpenVolumeMesh ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) 
	endif()
	

    
	if ( NOT WIN32 )
39
          set (TMP_FLAGS "-Wall -Wextra -Wuninitialized -Wunused -g -pedantic -ansi -Wno-long-long -Wno-variadic-macros ${CMAKE_CXX_FLAGS}")
40

41
	  # Set compiler flags
42 43
          set_target_properties(unittests PROPERTIES COMPILE_FLAGS "${TMP_FLAGS}")

44 45
	else()
	  # Set compiler flags
46
          set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" )
47 48

	  # copy exe file to "Build" directory
49 50 51 52
          # Visual studio will create this file in a subdirectory so we can't use
          # RUNTIME_OUTPUT_DIRECTORY directly here
          add_custom_command (TARGET unittests POST_BUILD
                              COMMAND ${CMAKE_COMMAND} -E
53 54 55 56 57 58 59 60 61 62
                                  copy_if_different
                                    ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/unittests.exe
                                    ${CMAKE_BINARY_DIR}/Unittests/unittests.exe)
	endif()
	
    acg_copy_after_build(unittests ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/)

else(GTEST_FOUND)
    message("Google testing framework was not found!")
endif(GTEST_FOUND)