Commit 26e58f7b authored by Jan Möbius's avatar Jan Möbius

Unittests for windows

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@427 fdac6126-5c0c-442c-9429-916003d36597
parent 1d363599
...@@ -599,7 +599,8 @@ RECURSIVE = YES ...@@ -599,7 +599,8 @@ RECURSIVE = YES
EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/Examples \ EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/Examples \
@CMAKE_CURRENT_SOURCE_DIR@/../src/OpenMesh/Tools/Test \ @CMAKE_CURRENT_SOURCE_DIR@/../src/OpenMesh/Tools/Test \
@CMAKE_CURRENT_SOURCE_DIR@/../src/OpenMesh/Apps/Unsupported @CMAKE_CURRENT_SOURCE_DIR@/../src/OpenMesh/Apps/Unsupported \
@CMAKE_CURRENT_BINARY_DIR@
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or # The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are excluded # directories that are symbolic links (a Unix filesystem feature) are excluded
......
...@@ -40,17 +40,20 @@ else(GTEST_INCLUDE_DIRS AND GTEST_LIBRARIES AND GTEST_MAIN_LIBRARIES) ...@@ -40,17 +40,20 @@ else(GTEST_INCLUDE_DIRS AND GTEST_LIBRARIES AND GTEST_MAIN_LIBRARIES)
PATHS PATHS
~/sw/gtest/include ~/sw/gtest/include
/opt/local/include /opt/local/include
/usr/local/include) /usr/local/include
"C:/libs/win32/gtest/include")
find_library(_GTEST_LIBRARY gtest find_library(_GTEST_LIBRARY gtest
PATHS PATHS
~/sw/gtest/lib ~/sw/gtest/lib
/opt/local/lib /opt/local/lib
/usr/local/lib) /usr/local/lib
"C:/libs/win32/gtest/lib")
find_library(_GTEST_MAIN_LIBRARY gtest_main find_library(_GTEST_MAIN_LIBRARY gtest_main
PATHS PATHS
~/sw/gtest/lib ~/sw/gtest/lib
/opt/local/lib /opt/local/lib
/usr/local/lib) /usr/local/lib
"C:/libs/win32/gtest/lib")
if ( _GTEST_LIBRARY ) if ( _GTEST_LIBRARY )
get_filename_component(_GTEST_LIBRARY_DIR ${_GTEST_LIBRARY} PATH CACHE ) get_filename_component(_GTEST_LIBRARY_DIR ${_GTEST_LIBRARY} PATH CACHE )
...@@ -61,10 +64,19 @@ else(GTEST_INCLUDE_DIRS AND GTEST_LIBRARIES AND GTEST_MAIN_LIBRARIES) ...@@ -61,10 +64,19 @@ else(GTEST_INCLUDE_DIRS AND GTEST_LIBRARIES AND GTEST_MAIN_LIBRARIES)
set(GTEST_FOUND true) set(GTEST_FOUND true)
set(GTEST_INCLUDE_DIRS ${_GTEST_INCLUDE_DIR} CACHE PATH set(GTEST_INCLUDE_DIRS ${_GTEST_INCLUDE_DIR} CACHE PATH
"Include directories for Google Test framework") "Include directories for Google Test framework")
set(GTEST_LIBRARIES ${_GTEST_LIBRARY} CACHE FILEPATH
"Libraries to link for Google Test framework") if ( NOT WIN32 )
set(GTEST_MAIN_LIBRARIES ${_GTEST_MAIN_LIBRARY} CACHE FILEPATH set(GTEST_LIBRARIES ${_GTEST_LIBRARY} CACHE FILEPATH
"Libraries to link for Google Test automatic main() definition") "Libraries to link for Google Test framework")
set(GTEST_MAIN_LIBRARIES ${_GTEST_MAIN_LIBRARY} CACHE FILEPATH
"Libraries to link for Google Test automatic main() definition")
else()
set(GTEST_LIBRARIES "optimized;gtest;debug;gtestd" CACHE FILEPATH
"Libraries to link for Google Test framework")
set(GTEST_MAIN_LIBRARIES "optimized;gtest_main;debug;gtest_maind" CACHE FILEPATH
"Libraries to link for Google Test automatic main() definition")
endif()
set(GTEST_LIBRARY_DIR ${_GTEST_LIBRARY_DIR} CACHE FILEPATH set(GTEST_LIBRARY_DIR ${_GTEST_LIBRARY_DIR} CACHE FILEPATH
"Library dir containing Google Test libraries") "Library dir containing Google Test libraries")
mark_as_advanced(GTEST_INCLUDE_DIRS GTEST_LIBRARIES GTEST_MAIN_LIBRARIES GTEST_LIBRARY_DIR ) mark_as_advanced(GTEST_INCLUDE_DIRS GTEST_LIBRARIES GTEST_MAIN_LIBRARIES GTEST_LIBRARY_DIR )
......
...@@ -16,12 +16,38 @@ if(GTEST_FOUND) ...@@ -16,12 +16,38 @@ if(GTEST_FOUND)
link_directories(${GTEST_LIBRARY_DIR} ) link_directories(${GTEST_LIBRARY_DIR} )
# Create new target named unittests_hexmeshing # Create new target named unittests_hexmeshing
add_executable(unittests EXCLUDE_FROM_ALL unittests.cc) add_executable(unittests EXCLUDE_FROM_ALL unittests.cc)
# Link against all necessary libraries
target_link_libraries(unittests OpenMeshCore OpenMeshTools gtest gtest_main pthread) if ( NOT WIN32)
# Set output directory to ${BINARY_DIR}/Unittests # Link against all necessary libraries
set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Unittests) target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
# Set compiler flags
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -ansi -Wno-long-long") # 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 OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
endif()
if ( NOT WIN32 )
# Set compiler flags
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -ansi -Wno-long-long")
else()
# Set compiler flags
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" )
# copy exe file to "Build" directory
# 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
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/) acg_copy_after_build(unittests ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/)
else(GTEST_FOUND) else(GTEST_FOUND)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment