Browse Source

Merge pull request #577 from g-pechorin/patch-4

not-git (and "nested" builds)
Alexander Gessler 10 years ago
parent
commit
36a9f2be1a

+ 2 - 2
CMakeLists.txt

@@ -23,7 +23,7 @@ add_definitions( -DOPENDDL_NO_USE_CPP11 )
 # Get the current working branch
 execute_process(
     COMMAND git rev-parse --abbrev-ref HEAD
-    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     OUTPUT_VARIABLE GIT_BRANCH
     OUTPUT_STRIP_TRAILING_WHITESPACE
 )
@@ -31,7 +31,7 @@ execute_process(
 # Get the latest abbreviated commit hash of the working branch
 execute_process(
     COMMAND git log -1 --format=%h
-    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     OUTPUT_VARIABLE GIT_COMMIT_HASH
     OUTPUT_STRIP_TRAILING_WHITESPACE
 )

+ 36 - 28
cmake-modules/AddGTest.cmake

@@ -30,35 +30,43 @@ endif()
 
 set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gtest")
 
-ExternalProject_Add(gtest
-	GIT_REPOSITORY https://chromium.googlesource.com/external/googletest
-	TIMEOUT 10
-	PREFIX "${GTEST_PREFIX}"
-	CMAKE_ARGS "${GTEST_CMAKE_ARGS}"
-	LOG_DOWNLOAD ON
-	LOG_CONFIGURE ON
-	LOG_BUILD ON
-	# Disable install
-	INSTALL_COMMAND ""
-)
+# try to find git - if found, setup gtest
+find_package(Git)
+if(NOT GIT_FOUND)
+	set(AddGTest_FOUND false CACHE BOOL "Was gtest setup correctly?")
+else(NOT GIT_FOUND)
+	set(AddGTest_FOUND true CACHE BOOL "Was gtest setup correctly?")
+	
+	ExternalProject_Add(gtest
+		GIT_REPOSITORY https://chromium.googlesource.com/external/googletest
+		TIMEOUT 10
+		PREFIX "${GTEST_PREFIX}"
+		CMAKE_ARGS "${GTEST_CMAKE_ARGS}"
+		LOG_DOWNLOAD ON
+		LOG_CONFIGURE ON
+		LOG_BUILD ON
+		# Disable install
+		INSTALL_COMMAND ""
+	)
 
-set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
-set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
-set(GTEST_LOCATION "${GTEST_PREFIX}/src/gtest-build")
-set(GTEST_DEBUG_LIBRARIES
-	"${GTEST_LOCATION}/${DEBUG_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}"
-	"${CMAKE_THREAD_LIBS_INIT}")
-SET(GTEST_RELEASE_LIBRARIES
-	"${GTEST_LOCATION}/${RELEASE_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}"
-	"${CMAKE_THREAD_LIBS_INIT}")
+	set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
+	set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
+	set(GTEST_LOCATION "${GTEST_PREFIX}/src/gtest-build")
+	set(GTEST_DEBUG_LIBRARIES
+		"${GTEST_LOCATION}/${DEBUG_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}"
+		"${CMAKE_THREAD_LIBS_INIT}")
+	SET(GTEST_RELEASE_LIBRARIES
+		"${GTEST_LOCATION}/${RELEASE_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}"
+		"${CMAKE_THREAD_LIBS_INIT}")
 
-if(MSVC_VERSION EQUAL 1700)
-  add_definitions(-D_VARIADIC_MAX=10)
-endif()
+	if(MSVC_VERSION EQUAL 1700)
+	  add_definitions(-D_VARIADIC_MAX=10)
+	endif()
 
-ExternalProject_Get_Property(gtest source_dir)
-include_directories(${source_dir}/include)
-include_directories(${source_dir}/gtest/include)
+	ExternalProject_Get_Property(gtest source_dir)
+	include_directories(${source_dir}/include)
+	include_directories(${source_dir}/gtest/include)
 
-ExternalProject_Get_Property(gtest binary_dir)
-link_directories(${binary_dir})
+	ExternalProject_Get_Property(gtest binary_dir)
+	link_directories(${binary_dir})
+endif(NOT GIT_FOUND)

+ 5 - 5
code/BaseImporter.cpp

@@ -155,11 +155,11 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
 		boost::scoped_array<char> _buffer (new char[searchBytes+1 /* for the '\0' */]);
 		char* buffer = _buffer.get();
 
-		const unsigned int read = pStream->Read(buffer,1,searchBytes);
+		const size_t read = pStream->Read(buffer,1,searchBytes);
 		if (!read)
 			return false;
 
-		for (unsigned int i = 0; i < read;++i)
+		for (size_t i = 0; i < read; ++i)
 			buffer[i] = ::tolower(buffer[i]);
 
 		// It is not a proper handling of unicode files here ...
@@ -392,11 +392,11 @@ void BaseImporter::ConvertToUTF8(std::vector<char>& data)
 // Convert to UTF8 data to ISO-8859-1
 void BaseImporter::ConvertUTF8toISO8859_1(std::string& data)
 {
-	unsigned int size = data.size();
-	unsigned int i = 0, j = 0;
+	size_t size = data.size();
+	size_t i = 0, j = 0;
 
 	while(i < size) {
-		if((unsigned char) data[i] < 0x80) {
+		if ((unsigned char) data[i] < (size_t) 0x80) {
 			data[j] = data[i];
 		} else if(i < size - 1) {
 			if((unsigned char) data[i] == 0xC2) {

+ 1 - 1
contrib/openddlparser/code/Value.cpp

@@ -80,7 +80,7 @@ void Value::setBool( bool value ) {
 
 bool Value::getBool() {
     assert( ddl_bool == m_type );
-    return ( bool ) ( *m_data );
+    return ( *m_data ) ? true : false;
 }
 
 void Value::setInt8( int8 value ) {

+ 2 - 0
test/CMakeLists.txt

@@ -46,6 +46,7 @@ SET( TEST_SRCS
 
 SOURCE_GROUP( tests FILES  ${TEST_SRCS} )
 
+if(AddGTest_FOUND)
 add_executable( unit
     unit/CCompilerTest.c
     unit/Main.cpp
@@ -60,5 +61,6 @@ target_link_libraries( unit assimp
 	debug ${GTEST_DEBUG_LIBRARIES}
 	optimized ${GTEST_RELEASE_LIBRARIES}
 )
+endif(AddGTest_FOUND)
 add_subdirectory(headercheck)
 

+ 3 - 1
tools/assimp_cmd/Main.h

@@ -46,7 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef AICMD_MAIN_INCLUDED
 #define AICMD_MAIN_INCLUDED
 
+#ifndef _CRT_SECURE_NO_WARNINGS
 #define _CRT_SECURE_NO_WARNINGS
+#endif
 
 #include <stdio.h>
 #include <string.h>
@@ -203,4 +205,4 @@ int Assimp_TestBatchLoad (
 	unsigned int num);
 
 
-#endif // !! AICMD_MAIN_INCLUDED
+#endif // !! AICMD_MAIN_INCLUDED