Fix unittests compilation for Windows.

This commit is contained in:
David Capello 2012-08-24 00:49:38 -03:00
parent d46616e71f
commit 33e3b5c8d0
3 changed files with 23 additions and 7 deletions

View File

@ -433,6 +433,12 @@ function(find_unittests dir dependencies)
include_directories(${CMAKE_SOURCE_DIR}/third_party/gtest/include)
endif()
# See if the test is linked with "she" library.
string(REGEX MATCH "she" link_with_she ${ARGV})
if (link_with_she STREQUAL "she")
set(extra_definitions -DLINKED_WITH_SHE)
endif()
foreach(testsourcefile ${tests})
get_filename_component(testname ${testsourcefile} NAME_WE)
@ -443,6 +449,11 @@ function(find_unittests dir dependencies)
PROPERTIES LINK_FLAGS ${LIBALLEGRO4_LINK_FLAGS})
endif()
if(extra_definitions)
set_target_properties(${testname}
PROPERTIES COMPILE_FLAGS ${extra_definitions})
endif()
add_custom_target(run_${testname}
COMMAND ${testname}
DEPENDS ${testname})

View File

@ -80,9 +80,3 @@ TEST(File, SeveralSizes)
}
}
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -28,7 +28,18 @@
#include "ui/gui.h"
#endif
int app_main(int argc, char* argv[])
#ifdef LINKED_WITH_SHE
#undef main
#ifdef WIN32
int main(int argc, char* argv[]) {
extern int app_main(int argc, char* argv[]);
return app_main(argc, argv);
}
#endif
#define main app_main
#endif
int main(int argc, char* argv[])
{
int exitcode;
::testing::InitGoogleTest(&argc, argv);