merging multitarget change into ProjectB/CMake

--- WkBuild.cmake
+++ WkBuild.cmake
@@ -60,6 +60,7 @@
 endmacro(WkIncludeDir dir)

 macro(WkSrcDir dir)
+	message (AUTHOR_WARNING "WkSrcDir is deprecated since multi target support has been added. You can now specify the source directory directly when calling WkLibraryBuild() or WkExecutableBuild().")
 	if (${PROJECT_NAME} STREQUAL "Project")
 		message(FATAL_ERROR "WkSrcDir has to be called after WkProject")
 	else ()
@@ -107,7 +108,7 @@
 	endif()

 	message(STATUS "= Configuring ${PROJECT_NAME}")
-    #TODO : check what happens if we have hierarchy of subdirectories with wkcmake projects
+	#TODO : check what happens if we have hierarchy of subdirectories with wkcmake projects
 	SET(${PROJECT_NAME}_CXX_COMPILER_LOADED "${CMAKE_CXX_COMPILER_LOADED}" CACHE INTERNAL "Whether C++ compiler has been loaded for the project or not" FORCE)
 	#TODO : make sure this doesnt get the C of CXX
 	SET(${PROJECT_NAME}_C_COMPILER_LOADED "${CMAKE_C_COMPILER_LOADED}" CACHE INTERNAL "Whether C compiler has been loaded for the project or not" FORCE)
@@ -130,12 +131,12 @@
 # Automatically called during WkBuild
 #

-macro ( WkGenConfig )
+macro ( WkGenConfig target_name)
 	CMAKE_POLICY(PUSH)
 	CMAKE_POLICY(VERSION 2.6)

 	#Exporting targets
-	export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}Export.cmake)
+	export(TARGETS ${target_name} FILE ${PROJECT_NAME}Export.cmake)

 	#Generating config file
 	file( WRITE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake "### Config file for ${PROJECT_NAME} auto generated by WkCmake ###
@@ -156,7 +157,7 @@

 	file( APPEND ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake "
 #however we still want to have ${PROJECT_NAME}_LIBRARIES available
-set(${PROJECT_NAME}_LIBRARY ${PROJECT_NAME} )
+set(${PROJECT_NAME}_LIBRARY ${${PROJECT_NAME}_LIBRARY} )
 set(${PROJECT_NAME}_LIBRARIES \"\${${PROJECT_NAME}_LIBRARY}\")
 	" )

@@ -196,61 +197,326 @@
 # You need include and src in your hierarchy at least for this to work correctly
 #

-#WkBuild( EXECUTABLE | LIBRARY [ STATIC|SHARED|MODULE ]  )
+#WkBuild( EXECUTABLE | LIBRARY [ STATIC|SHARED|MODULE ] [source_dir] )

 macro (WkBuild project_type)
 CMAKE_POLICY(PUSH)
 CMAKE_POLICY(VERSION 2.6)
-
+	WkSrcDir("src")
+	message(AUTHOR_WARNING "WkBuild is deprecated. Please use WkLibraryBuild or WkExecutableBuild instead.")
+	if ( ${project_type} STREQUAL EXECUTABLE )
+		if ( ${ARGC} GREATER 1 AND EXISTS ${ARGV1} AND IS_DIRECTORY ${ARGV1} )
+			if (${PROJECT_NAME}_SRC_DIR)
+				message(WARNING "${ARGV1} will override ${${PROJECT_NAME}_SRC_DIR} as source directory for ${PROJECT_NAME}")
+			endif(${PROJECT_NAME}_SRC_DIR)
+			set(${PROJECT_NAME}_SRC_DIR ${ARGV1} )
+		endif ( ${ARGC} GREATER 1 AND EXISTS ${ARGV1} AND IS_DIRECTORY ${ARGV1} )
+		message(STATUS "Using default Source directory : ${${PROJECT_NAME}_SRC_DIR} ")
+		WkExecutableBuild(${PROJECT_NAME} ${${PROJECT_NAME}_SRC_DIR})
+	elseif ( ${project_type} STREQUAL LIBRARY )
+		if ( ${ARGC} GREATER 1 )
+			if ( ${ARGV1} STREQUAL STATIC OR ${ARGV1} STREQUAL SHARED OR ${ARGV1} STREQUAL MODULE )
+				set(${PROJECT_NAME}_load_type ${ARGV1} )
+				if ( ${ARGC} GREATER 2)
+					if( EXISTS ${ARGV2} AND IS_DIRECTORY ${ARGV2} )
+						if (${PROJECT_NAME}_SRC_DIR)
+							message(WARNING "${ARGV2} will override ${${PROJECT_NAME}_SRC_DIR} as source directory for ${PROJECT_NAME}")
+						endif(${PROJECT_NAME}_SRC_DIR)
+						set(${PROJECT_NAME}_SRC_DIR ${ARGV2} )
+					endif( EXISTS ${ARGV2} AND IS_DIRECTORY ${ARGV2} )
+				endif()
+			elseif ( EXISTS ${ARGV1} AND IS_DIRECTORY ${ARGV1} )
+				if (${PROJECT_NAME}_SRC_DIR)
+					message(WARNING "${ARGV1} will override ${${PROJECT_NAME}_SRC_DIR} as source directory for ${PROJECT_NAME}")
+				endif(${PROJECT_NAME}_SRC_DIR)
+				set(${PROJECT_NAME}_SRC_DIR ${ARGV1} )
+			endif ()
+		endif ( ${ARGC} GREATER 1 )
+		message(STATUS "Using default Source directory : ${${PROJECT_NAME}_SRC_DIR} ")
+		WkLibraryBuild(${PROJECT_NAME} ${${PROJECT_NAME}_load_type} ${${PROJECT_NAME}_SRC_DIR})
+	else()
+		message(FATAL_ERROR "WkBuild called with project_type = ${project_type}. It can be either EXECUTABLE or LIBRARY.")
+	endif()
+
+	WkExportConfig( ${PROJECT_NAME} )
+
+CMAKE_POLICY(POP)
+endmacro (WkBuild)
+
+#WkLibraryBuild generates a library target for the current project.
+#with same Language as Project and implicit dependency as the main build target
+# and also with same doc, tests, etc.
+# only source files and include directories are different
+# WkLibraryBuild ( target_name [STATIC|SHARED|MODULE] source_dir )
+macro (WkLibraryBuild target_name )
+CMAKE_POLICY(PUSH)
+CMAKE_POLICY(VERSION 2.6)
+
+	#to be able to include() from another directory
+	if ( NOT CMAKE_MODULE_PATH )
+		set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/${${PROJECT_NAME}_DIR}/Modules/")
+	endif ( NOT CMAKE_MODULE_PATH )
+
+	#adding WKCMAKE_SHARED_LIBS option
+	option(WKCMAKE_SHARED_LIBS "Set this to ON to build shared libraries by default" off)
+
+	#parsing extra arguments
 	if ( ${ARGC} GREATER 1 )
-		set(${PROJECT_NAME}_load_type ${ARGV1} )
+		if ( NOT ${ARGV1} STREQUAL "STATIC"
+		     AND NOT ${ARGV1} STREQUAL "SHARED"
+		     AND NOT ${ARGV1} STREQUAL "MODULE"
+		)
+			#assuming it s the source dir
+			set(${target_name}_SRC_DIR ${ARGV1} )
+			if( WKCMAKE_SHARED_LIBS )
+				set(${target_name}_load_type "SHARED")
+			else( WKCMAKE_SHARED_LIBS )
+				set(${target_name}_load_type "STATIC")
+			endif( WKCMAKE_SHARED_LIBS )
+		else()
+			set(${target_name}_load_type ${ARGV1} )
+			if ( ${ARGC} GREATER 2 )
+				set(${target_name}_SRC_DIR ${ARGV2} )
+			endif ( ${ARGC} GREATER 2 )
+		endif()
 	endif ( ${ARGC} GREATER 1 )

-    #Setting up project structure defaults for directories
-    # Note that if these have been already defined with the same macros, the calls here wont have any effect ( wont changed cached value )
-    WkIncludeDir("include")
-	WkSrcDir("src")
-	WkBinDir("bin")
+	message ( STATUS "== Configuring ${target_name} as LIBRARY ${${target_name}_load_type}" )
+
+	#Setting up project structure defaults for directories
+	# Note that if these have been already defined with the same macros, the calls here wont have any effect ( wont changed cached value )
+	WkIncludeDir("include")
 	WkLibDir("lib")
 	WkDataDir("data")
-
-    #Doing compiler setup in Build step, because :
-    # - it is related to target, not overall project ( even if environment is same for cmake, settings can be different for each target )
-    # - custom build options may have been defined before ( and will be used instead of defaults )
+
+	#Doing compiler setup in Build step, because :
+	# - it is related to target, not overall project ( even if environment is same for cmake, settings can be different for each target )
+	# - custom build options may have been defined before ( and will be used instead of defaults )
 	WkCompilerSetup()

-    #adding usual BUILD_SHARED_LIBS option
-    option(BUILD_SHARED_LIBS "Set this to ON to build shared libraries by default" off)
-
-	if(${project_type} STREQUAL "LIBRARY")
-		#handling default load type
-		if ( NOT ${PROJECT_NAME}_load_type )
-		    if( BUILD_SHARED_LIBS )
-    		    set(${PROJECT_NAME}_load_type "SHARED")
-    		else( BUILD_SHARED_LIBS )
-        		set(${PROJECT_NAME}_load_type "STATIC")
-        	endif( BUILD_SHARED_LIBS )
-        endif ( NOT ${PROJECT_NAME}_load_type )
-	endif(${project_type} STREQUAL "LIBRARY")
-
-	message ( STATUS "== Configuring ${PROJECT_NAME} as ${project_type} ${${PROJECT_NAME}_load_type}" )
-
-	# testing type
-	if (NOT ${project_type} STREQUAL "EXECUTABLE" AND NOT ${project_type} STREQUAL "LIBRARY" )
-		message ( FATAL_ERROR " Project type ${project_type} is not valid. Project type can be either EXECUTABLE or LIBRARY")
-	endif (NOT ${project_type} STREQUAL "EXECUTABLE" AND NOT ${project_type} STREQUAL "LIBRARY" )
-	if ( ${project_type} STREQUAL "LIBRARY"
-					AND NOT ${${PROJECT_NAME}_load_type} STREQUAL "STATIC"
-					AND NOT ${${PROJECT_NAME}_load_type} STREQUAL "SHARED"
-					AND NOT ${${PROJECT_NAME}_load_type} STREQUAL "MODULE"
+	#configuration depending on build type
+	WkBuildTypeConfig()
+
+	#generating configured Header for detected packages
+	WkPlatformConfigure()
+
+	#globbing source files
+	message ( STATUS "== Gathering source files for ${target_name} in ${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} and ${${target_name}_SRC_DIR}..." )
+
+	FILE(GLOB_RECURSE ${target_name}_HEADERS RELATIVE "${PROJECT_SOURCE_DIR}"
+		${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}/*.h
+		${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}/*.hh
+		${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}/*.hpp
+		${${target_name}_SRC_DIR}/*.h
+		${${target_name}_SRC_DIR}/*.hh
+		${${target_name}_SRC_DIR}/*.hpp
+	)
+	FILE(GLOB_RECURSE ${target_name}_SOURCES RELATIVE "${PROJECT_SOURCE_DIR}"
+		${${target_name}_SRC_DIR}/*.c
+		${${target_name}_SRC_DIR}/*.cpp
+		${${target_name}_SRC_DIR}/*.cc
+	)
+	message ( STATUS "== Headers detected in ${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} and ${${target_name}_SRC_DIR} : ${${target_name}_HEADERS}" )
+	message ( STATUS "== Sources detected in ${${target_name}_SRC_DIR} : ${${target_name}_SOURCES}" )
+
+	# to show we are using WkCMake to build ( can be #ifdef in header )
+	add_definitions( -D WK_BUILD )
+
+	#TODO : find a simpler way than this complex merge...
+	MERGE("${${target_name}_HEADERS}" "${${target_name}_SOURCES}" ${target_name}_SOURCES)
+	#MESSAGE ( STATUS "== ${target_name} Sources : ${${target_name}_SOURCES}" )
+
+	AddPlatformCheckSrc(${target_name}_SOURCES)
+
+	#Setting up AStyle target
+	WkTargetFormat(${target_name} ${${target_name}_SOURCES})
+
+	#internal headers ( non visible by outside project )
+	include_directories("${PROJECT_SOURCE_DIR}/${${target_name}_SRC_DIR}")
+
+	#Including configured headers (
+	#	-binary_dir/CMakeFiles for the configured header,
+	#	-source_dir/include for the unmodified ones,
+	include_directories("${PROJECT_BINARY_DIR}/CMakeFiles" "${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}" )
+
+	add_library(${target_name} ${${target_name}_load_type} ${${target_name}_SOURCES})
+
+	#defining where to put what has been built
+	SET(${CMAKE_PROJECT_NAME}_LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${${CMAKE_PROJECT_NAME}_LIB_DIR} CACHE PATH "Ouput directory for ${PROJECT_NAME} libraries." )
+	mark_as_advanced(FORCE ${CMAKE_PROJECT_NAME}_LIBRARY_OUTPUT_PATH)
+	SET(LIBRARY_OUTPUT_PATH "${${CMAKE_PROJECT_NAME}_LIBRARY_OUTPUT_PATH}" CACHE INTERNAL "Internal CMake libraries output directory. Do not edit." FORCE)
+
+	# adding dependencies for cppcheck ( and format ) targets
+	WkTargetCppCheck(${PROJECT_NAME})
+
+	#storing a variable for top project to be able to link it
+	if ( ${PROJECT_NAME}_LIBRARY AND NOT "${${PROJECT_NAME}_LIBRARY}" STREQUAL "")
+		LIST(FIND ${PROJECT_NAME}_LIBRARY ${target_name} already_stored)
+		IF( already_stored LESS 0)
+			set(${PROJECT_NAME}_LIBRARY ${${PROJECT_NAME}_LIBRARY} ${target_name} CACHE FILEPATH "${PROJECT_NAME} ${target_name} Library" FORCE)
+		ENDIF( already_stored LESS 0)
+	else()
+		set(${PROJECT_NAME}_LIBRARY "${target_name}" CACHE FILEPATH "${PROJECT_NAME} ${target_name} Library")
+	endif()
+
+	if ( ${${target_name}_load_type} STREQUAL "SHARED" )
+		set_target_properties(${target_name} PROPERTIES DEFINE_SYMBOL "WK_${PROJECT_NAME}_${target_name}_SHAREDLIB_BUILD")
+	endif ( ${${target_name}_load_type} STREQUAL "SHARED" )
+
+	if ( EXISTS ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} )
+		ADD_CUSTOM_COMMAND(
+			TARGET ${target_name}
+			POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
+			"${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}" "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}"
+			COMMENT
+			"Copying ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} to ${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}"
 		)
-		message ( FATAL_ERROR " Project Load type ${${PROJECT_NAME}_load_type} is not valid. Project Load type can be either STATIC, SHARED or MODULE")
-	endif  ( ${project_type} STREQUAL "LIBRARY"
-					AND NOT ${${PROJECT_NAME}_load_type} STREQUAL "STATIC"
-					AND NOT ${${PROJECT_NAME}_load_type} STREQUAL "SHARED"
-					AND NOT ${${PROJECT_NAME}_load_type} STREQUAL "MODULE"
+	else()
+		message ( WARNING "Directory ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} NOT FOUND !" )
+		message ( WARNING "Headers for ${target_name} cannot be copied !" )
+	endif()
+
+	WkTargetSetProperties (${target_name})
+
+	#
+	# Copying data directory after build ( for use by project later )
+	#
+	ADD_CUSTOM_COMMAND( TARGET ${target_name} POST_BUILD
+		COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
+		"${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_DATA_DIR}" "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_DATA_DIR}"
+		COMMENT
+		"Copying ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_DATA_DIR} to ${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_DATA_DIR}"
+	)
+
+CMAKE_POLICY(POP)
+endmacro(WkLibraryBuild)
+
+#WkLibraryBuild generates a library target for the current project.
+#with same Language as Project and implicit dependency as the main build target
+# and also with same doc, tests, etc.
+# only source files and include directories are different
+# WkLibraryBuild ( target_name load_type source_dir)
+macro (WkExecutableBuild target_name )
+CMAKE_POLICY(PUSH)
+CMAKE_POLICY(VERSION 2.6)
+
+	#to be able to include() from another directory
+	if ( NOT CMAKE_MODULE_PATH )
+		set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/${${PROJECT_NAME}_DIR}/Modules/")
+	endif ( NOT CMAKE_MODULE_PATH )
+
+	#Setting up project structure defaults for directories
+	# Note that if these have been already defined with the same macros, the calls here wont have any effect ( wont changed cached value )
+	WkIncludeDir("include")
+	WkBinDir("bin")
+	WkDataDir("data")
+
+	#Doing compiler setup in Build step, because :
+	# - it is related to target, not overall project ( even if environment is same for cmake, settings can be different for each target )
+	# - custom build options may have been defined before ( and will be used instead of defaults )
+	WkCompilerSetup()
+
+	#configuration depending on build type
+	WkBuildTypeConfig()
+
+	#generating configured Header for detected packages
+	WkPlatformConfigure()
+
+	#globbing source files
+	message ( STATUS "== Gathering source files for ${target_name} in ${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} and ${${PROJECT_NAME}_INCLUDE_DIR} and ${${target_name}_SRC_DIR}..." )
+
+	FILE(GLOB_RECURSE ${target_name}_HEADERS RELATIVE "${PROJECT_SOURCE_DIR}"
+		${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}/*.h
+		${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}/*.hh
+		${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}/*.hpp
+		${${PROJECT_NAME}_INCLUDE_DIR}/*.h
+		${${PROJECT_NAME}_INCLUDE_DIR}/*.hh
+		${${PROJECT_NAME}_INCLUDE_DIR}/*.hpp
+		${${target_name}_SRC_DIR}/*.h
+		${${target_name}_SRC_DIR}/*.hh
+		${${target_name}_SRC_DIR}/*.hpp
+	)
+	FILE(GLOB_RECURSE ${target_name}_SOURCES RELATIVE "${PROJECT_SOURCE_DIR}"
+		${${target_name}_SRC_DIR}/*.c
+		${${target_name}_SRC_DIR}/*.cpp
+		${${target_name}_SRC_DIR}/*.cc
+	)
+	message ( STATUS "== Headers detected in ${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} and ${${target_name}_SRC_DIR} : ${${target_name}_HEADERS}" )
+	message ( STATUS "== Sources detected in ${${target_name}_SRC_DIR} : ${${target_name}_SOURCES}" )
+
+	# to show we are using WkCMake to build ( can be #ifdef in header )
+	add_definitions( -D WK_BUILD )
+
+	#TODO : find a simpler way than this complex merge...
+	MERGE("${${target_name}_HEADERS}" "${${target_name}_SOURCES}" ${target_name}_SOURCES)
+	#MESSAGE ( STATUS "== ${PROJECT_NAME} Sources : ${SOURCES}" )
+
+	AddPlatformCheckSrc(${target_name}_SOURCES)
+
+	#Setting up AStyle target
+	WkTargetFormat(${target_name} ${${target_name}_SOURCES})
+
+	#internal headers ( non visible by outside project )
+	include_directories("${PROJECT_SOURCE_DIR}/${${target_name}_SRC_DIR}")
+
+	#Including configured headers (
+	#	-binary_dir/CMakeFiles for the configured header,
+	#	-source_dir/include for the unmodified ones,
+	include_directories("${PROJECT_BINARY_DIR}/CMakeFiles" "${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}" )
+
+	add_executable(${target_name} ${${target_name}_SOURCES})
+
+	SET(${CMAKE_PROJECT_NAME}_RUNTIME_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${${CMAKE_PROJECT_NAME}_BIN_DIR} CACHE PATH "Ouput directory for ${PROJECT_NAME} executables." )
+	mark_as_advanced(FORCE ${CMAKE_PROJECT_NAME}_RUNTIME_OUTPUT_PATH)
+	SET(RUNTIME_OUTPUT_PATH "${${CMAKE_PROJECT_NAME}_RUNTIME_OUTPUT_PATH}" CACHE INTERNAL "Internal CMake executables output directory. Do not edit." FORCE)
+
+	# adding dependencies for cppcheck ( and format ) targets
+	WkTargetCppCheck(${PROJECT_NAME})
+
+	#storing a variable for top project to be able to link it
+	if ( ${PROJECT_NAME}_LIBRARY AND NOT "${${PROJECT_NAME}_LIBRARY}" STREQUAL "")
+		STRING(FIND ${${PROJECT_NAME}_LIBRARY} ${target_name} already_stored)
+		IF( NOT already_stored)
+			set(${PROJECT_NAME}_LIBRARY ${${PROJECT_NAME}_LIBRARY} ${target_name} CACHE FILEPATH "${PROJECT_NAME} ${target_name} Library" FORCE)
+		ENDIF(NOT already_stored)
+	else()
+		set(${PROJECT_NAME}_LIBRARY "${target_name}" CACHE FILEPATH "${PROJECT_NAME} ${target_name} Library")
+	endif()
+
+	if ( ${${target_name}_load_type} STREQUAL "SHARED" )
+		set_target_properties(${target_name} PROPERTIES DEFINE_SYMBOL "WK_${PROJECT_NAME}_${target_name}_SHAREDLIB_BUILD")
+	endif ( ${${target_name}_load_type} STREQUAL "SHARED" )
+
+	if ( EXISTS ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} )
+		ADD_CUSTOM_COMMAND(
+			TARGET ${target_name}
+			POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
+			"${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}" "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}"
+			COMMENT
+			"Copying ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} to ${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name}"
 		)
-
+	else()
+		message ( WARNING "Directory ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/${target_name} NOT FOUND !" )
+		message ( WARNING "Headers for ${target_name} cannot be copied !" )
+	endif()
+
+	WkTargetSetProperties (${target_name})
+
+	#
+	# Copying data directory after build ( for use by project later )
+	#
+	ADD_CUSTOM_COMMAND( TARGET ${target_name} POST_BUILD
+		COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
+		"${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_DATA_DIR}" "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_DATA_DIR}"
+		COMMENT
+		"Copying ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_DATA_DIR} to ${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_DATA_DIR}"
+	)
+
+CMAKE_POLICY(POP)
+endmacro(WkExecutableBuild)
+
+macro (WkBuildTypeConfig)
+
 	#Verbose Makefile if not release build. Making them internal not to confuse user by appearing with values used only for one project.
 	if ( ${PROJECT_NAME}_BUILD_TYPE )
 	if (${${PROJECT_NAME}_BUILD_TYPE} STREQUAL Release)
@@ -260,194 +526,69 @@
 		message( STATUS "== Non Release build detected : enabling verbose makefile" )
 		# To get the actual commands used
 		set(CMAKE_VERBOSE_MAKEFILE ON CACHE INTERNAL "Verbose build commands enabled for Non Release build." FORCE)
-				#VLD
-		set(CHECK_MEM_LEAKS OFF CACHE BOOL "On to check memory with VLD (must be installed)")
-		if(CHECK_MEM_LEAKS)
+		#VLD
+		set(WKCMAKE_CHECK_MEMORY OFF CACHE BOOL "On to check memory with VLD (must be installed)")
+		if(WKCMAKE_CHECK_MEMORY)
 			add_definitions(-DVLD)
-		endif(CHECK_MEM_LEAKS)
+		endif(WKCMAKE_CHECK_MEMORY)
 	endif (${${PROJECT_NAME}_BUILD_TYPE} STREQUAL Release)
 	endif ( ${PROJECT_NAME}_BUILD_TYPE )

-	#generating configured Header for detected packages
-	WkPlatformConfigure()
-
-	#Storing Main Include directory
-	#set( ${PROJECT_NAME}_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}" CACHE PATH " Includes directories for ${PROJECT_NAME} blah ")
-
-	#Defining target
-	message ( STATUS "== Sources Files autodetection..." )
-
-	#VS workaround to display headers even if strictly not needed when building
-	FILE(GLOB_RECURSE HEADERS RELATIVE "${PROJECT_SOURCE_DIR}" ${${PROJECT_NAME}_INCLUDE_DIR}/*.h ${${PROJECT_NAME}_INCLUDE_DIR}/*.hh ${${PROJECT_NAME}_INCLUDE_DIR}/*.hpp ${${PROJECT_NAME}_SRC_DIR}/*.h ${${PROJECT_NAME}_SRC_DIR}/*.hh ${${PROJECT_NAME}_SRC_DIR}/*.hpp)
-	FILE(GLOB_RECURSE SOURCES RELATIVE "${PROJECT_SOURCE_DIR}" ${${PROJECT_NAME}_SRC_DIR}/*.c ${${PROJECT_NAME}_SRC_DIR}/*.cpp ${${PROJECT_NAME}_SRC_DIR}/*.cc)
-	message ( STATUS "== Headers detected in ${${PROJECT_NAME}_INCLUDE_DIR} and ${${PROJECT_NAME}_SRC_DIR} : ${HEADERS}" )
-	message ( STATUS "== Sources detected in ${${PROJECT_NAME}_SRC_DIR} : ${SOURCES}" )
-
-	if ( NOT CMAKE_MODULE_PATH )
-		set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/${${PROJECT_NAME}_DIR}/Modules/")
-	endif ( NOT CMAKE_MODULE_PATH )
-
-	#TODO : automatic detectino on windows ( preinstalled with wkcmake... )
-	FIND_PACKAGE(WKCMAKE_AStyle)
-	IF ( WKCMAKE_AStyle_FOUND )
-		option (${PROJECT_NAME}_CODE_FORMAT "Enable Code Formatting" OFF)
-		IF ( ${PROJECT_NAME}_CODE_FORMAT )
-			set(${PROJECT_NAME}_CODE_FORMAT_STYLE "ansi" CACHE STRING "Format Style for AStyle")
-			#converting to system path ( needed because command line call later )
-			set(HEADERS_NATIVE "")
-			foreach (f ${HEADERS} )
-				FILE(TO_NATIVE_PATH ${f} f_nat)
-				SET(HEADERS_NATIVE ${HEADERS_NATIVE} ${f_nat})
-			endforeach(f)
-			SET(SOURCES_NATIVE "")
-			foreach (f ${SOURCES} )
-				FILE(TO_NATIVE_PATH ${f} f_nat)
-				SET(SOURCES_NATIVE ${SOURCES_NATIVE} ${f_nat})
-			endforeach(f)
-			WkWhitespaceSplit( HEADERS_NATIVE HEADERS_PARAM_NATIVE )
-			WkWhitespaceSplit( SOURCES_NATIVE SOURCES_PARAM_NATIVE )
-			#message ( "Sources :  ${HEADERS_PARAM_NATIVE} ${SOURCES_PARAM_NATIVE}" )
-			set ( cmdline " ${WKCMAKE_AStyle_EXECUTABLE} --style=${${PROJECT_NAME}_CODE_FORMAT_STYLE} ${HEADERS_PARAM_NATIVE} ${SOURCES_PARAM_NATIVE}" )
-			#message ( "CMD : ${cmdline} " )
-			#message ( "WORKING_DIR : ${PROJECT_SOURCE_DIR} " )
-			IF ( WIN32 )
-				ADD_CUSTOM_TARGET(${PROJECT_NAME}_format ALL cmd /c ${cmdline} WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM )
-			ELSE ( WIN32 )
-				ADD_CUSTOM_TARGET(${PROJECT_NAME}_format ALL sh -c ${cmdline} WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM )
-			ENDIF ( WIN32 )
-		ENDIF ( ${PROJECT_NAME}_CODE_FORMAT )
-	ENDIF ( WKCMAKE_AStyle_FOUND )
-
-
-	#Including configured headers (
-	#	-binary_dir/CMakeFiles for the configured header,
-	#	-source_dir/include for the unmodified ones,
-	include_directories("${PROJECT_BINARY_DIR}/CMakeFiles" "${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}" )
-
-	#internal headers ( non visible by outside project )
-	include_directories("${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_SRC_DIR}")
-
-	#TODO : find a simpler way than this complex merge...
-	MERGE("${HEADERS}" "${SOURCES}" SOURCES)
-	#MESSAGE ( STATUS "== ${PROJECT_NAME} Sources : ${SOURCES}" )
-
-	AddPlatformCheckSrc( SOURCES )
-
-	#
-	# Handling my own build config
-	#
-
-	# to show we are using WkCMake to build ( can be #ifdef in header )
-	add_definitions( -D WK_BUILD )
-
-	if(${project_type} STREQUAL "LIBRARY")
-		add_library(${PROJECT_NAME} ${${PROJECT_NAME}_load_type} ${SOURCES})
-		#storing a variable for top project to be able to link it
-		set(${PROJECT_NAME}_LIBRARY ${PROJECT_NAME} CACHE FILEPATH "${PROJECT_NAME} Library")
-		if ( ${${PROJECT_NAME}_load_type} STREQUAL "SHARED" )
-			set_target_properties(${PROJECT_NAME} PROPERTIES DEFINE_SYMBOL "WK_${PROJECT_NAME}_SHAREDLIB_BUILD")
-		endif ( ${${PROJECT_NAME}_load_type} STREQUAL "SHARED" )
-	elseif (${project_type} STREQUAL "EXECUTABLE")
-		add_executable(${PROJECT_NAME} ${SOURCES})
-		#We also need to copy run libraries on windows
-
-	else ()
-		message( FATAL_ERROR " Project Type can only be EXECUTABLE or LIBRARY " )
-	endif()
-
+endmacro (WkBuildTypeConfig)
+
+
+macro (WkTargetSetProperties target_name )
 	#setting target properties
 	#Need to match WkCompilerSetup content
-    if ( ${PROJECT_NAME}_C_COMPILER_LOADED )
-        if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
-            set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_C_FLAGS} ${${PROJECT_NAME}_C_FLAGS_DEBUG}" )
-        elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
-            set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_C_FLAGS} ${${PROJECT_NAME}_C_FLAGS_RELEASE}" )
-        endif()
-    endif()
-    if ( ${PROJECT_NAME}_CXX_COMPILER_LOADED )
-        if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
-            set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_CXX_FLAGS} ${${PROJECT_NAME}_CXX_FLAGS_DEBUG}" )
-        elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
-            set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_CXX_FLAGS} ${${PROJECT_NAME}_CXX_FLAGS_RELEASE}" )
-        endif()
-    endif()
-	get_target_property(${PROJECT_NAME}_TYPE ${PROJECT_NAME} TYPE)
+	if ( ${PROJECT_NAME}_C_COMPILER_LOADED )
+		if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
+			set_target_properties( ${target_name} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_C_FLAGS} ${${PROJECT_NAME}_C_FLAGS_DEBUG}" )
+		elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
+			set_target_properties( ${target_name} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_C_FLAGS} ${${PROJECT_NAME}_C_FLAGS_RELEASE}" )
+		endif()
+	endif()
+	if ( ${PROJECT_NAME}_CXX_COMPILER_LOADED )
+		if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
+			set_target_properties( ${target_name} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_CXX_FLAGS} ${${PROJECT_NAME}_CXX_FLAGS_DEBUG}" )
+		elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
+			set_target_properties( ${target_name} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_CXX_FLAGS} ${${PROJECT_NAME}_CXX_FLAGS_RELEASE}" )
+		endif()
+	endif()
+	get_target_property(${PROJECT_NAME}_TYPE ${target_name} TYPE)
 	if ( ${PROJECT_NAME}_TYPE STREQUAL "SHARED_LIBRARY" )
-        set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS "${${PROJECT_NAME}_SHARED_LINKER_FLAGS}" )
- 	    if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
-     	    set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "${${PROJECT_NAME}_SHARED_LINKER_FLAGS_DEBUG}" )
-   	    elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
-       	    set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "${${PROJECT_NAME}_SHARED_LINKER_FLAGS_RELEASE}" )
-        endif()
-    elseif( ${PROJECT_NAME}_TYPE STREQUAL "MODULE_LIBRARY" )
-   	    set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS "${${PROJECT_NAME}_MODULE_LINKER_FLAGS}" )
-        if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
-     	    set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "${${PROJECT_NAME}_MODULE_LINKER_FLAGS_DEBUG}" )
-        elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
-       	    set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "${${PROJECT_NAME}_MODULE_LINKER_FLAGS_RELEASE}" )
-        endif()
-  	elseif( ${PROJECT_NAME}_TYPE STREQUAL "EXECUTABLE" )
-  	    if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
-     	    set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "${${PROJECT_NAME}_EXE_LINKER_FLAGS} ${${PROJECT_NAME}_EXE_LINKER_FLAGS_DEBUG}" )
-        elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
-      	    set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "${${PROJECT_NAME}_EXE_LINKER_FLAGS} ${${PROJECT_NAME}_EXE_LINKER_FLAGS_RELEASE}" )
-        endif()
-  	endif()
-
-	#code analysis by target introspection -> needs to be done after target definition ( as here )
-	FIND_PACKAGE(WKCMAKE_Cppcheck)
-	IF ( WKCMAKE_Cppcheck_FOUND)
-		option ( ${PROJECT_NAME}_CODE_ANALYSIS "Enable Code Analysis" OFF)
-		IF ( ${PROJECT_NAME}_CODE_ANALYSIS )
-			Add_WKCMAKE_Cppcheck_target(${PROJECT_NAME}_cppcheck ${PROJECT_NAME} "${PROJECT_NAME}-cppcheck.xml")
-		ENDIF ( ${PROJECT_NAME}_CODE_ANALYSIS )
-	ENDIF ( WKCMAKE_Cppcheck_FOUND)
-
-    #setting up dependencies between formatting and code analysis target
-	if ( WKCMAKE_Cppcheck_FOUND AND ${PROJECT_NAME}_CODE_ANALYSIS )
-		add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_cppcheck)
-    	if( WKCMAKE_AStyle_FOUND AND ${PROJECT_NAME}_CODE_FORMAT )
-    		add_dependencies(${PROJECT_NAME}_cppcheck ${PROJECT_NAME}_format)
-        endif( WKCMAKE_AStyle_FOUND AND ${PROJECT_NAME}_CODE_FORMAT )
-    else ( WKCMAKE_Cppcheck_FOUND AND ${PROJECT_NAME}_CODE_ANALYSIS )
-    	if( WKCMAKE_AStyle_FOUND AND ${PROJECT_NAME}_CODE_FORMAT )
-    		add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_format)
-        endif( WKCMAKE_AStyle_FOUND AND ${PROJECT_NAME}_CODE_FORMAT )
-    endif( WKCMAKE_Cppcheck_FOUND AND ${PROJECT_NAME}_CODE_ANALYSIS )
-
-	#
-	# Defining where to put what has been built
-	#
-
-	SET(${CMAKE_PROJECT_NAME}_LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${${CMAKE_PROJECT_NAME}_LIB_DIR} CACHE PATH "Ouput directory for ${Project} libraries." )
-	mark_as_advanced(FORCE ${CMAKE_PROJECT_NAME}_LIBRARY_OUTPUT_PATH)
-	SET(LIBRARY_OUTPUT_PATH "${${CMAKE_PROJECT_NAME}_LIBRARY_OUTPUT_PATH}" CACHE INTERNAL "Internal CMake libraries output directory. Do not edit." FORCE)
-
-	SET(${CMAKE_PROJECT_NAME}_EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${${CMAKE_PROJECT_NAME}_BIN_DIR} CACHE PATH "Ouput directory for ${Project} executables." )
-	mark_as_advanced(FORCE ${CMAKE_PROJECT_NAME}_EXECUTABLE_OUTPUT_PATH)
-	SET(EXECUTABLE_OUTPUT_PATH "${${CMAKE_PROJECT_NAME}_EXECUTABLE_OUTPUT_PATH}" CACHE INTERNAL "Internal CMake executables output directory. Do not edit." FORCE)
-
-	#
-	# Copying include directory if needed after build ( for  use by another project later )
-	# for library (and modules ? )
-	#
-
-	if(${project_type} STREQUAL "LIBRARY")
-		ADD_CUSTOM_COMMAND( TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}" "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}" COMMENT "Copying ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_INCLUDE_DIR} to ${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}" )
-		#trying to remove .svn directory... pb : what about other directories everywhere ?
-		ADD_CUSTOM_COMMAND( TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E remove_directory "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/.svn" COMMENT "Removing ${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_INCLUDE_DIR}/.svn" )
-	endif(${project_type} STREQUAL "LIBRARY")
-
-	#
-	# Copying data directory after build ( fo use by project later )
-	#
-	ADD_CUSTOM_COMMAND( TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_DATA_DIR}" "${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_DATA_DIR}" COMMENT "Copying ${PROJECT_SOURCE_DIR}/${${PROJECT_NAME}_DATA_DIR} to ${PROJECT_BINARY_DIR}/${${PROJECT_NAME}_DATA_DIR}" )
+		set_target_properties( ${target_name} PROPERTIES LINK_FLAGS "${${PROJECT_NAME}_SHARED_LINKER_FLAGS}" )
+		if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
+			set_target_properties( ${target_name} PROPERTIES LINK_FLAGS_DEBUG "${${PROJECT_NAME}_SHARED_LINKER_FLAGS_DEBUG}" )
+		elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
+			set_target_properties( ${target_name} PROPERTIES LINK_FLAGS_RELEASE "${${PROJECT_NAME}_SHARED_LINKER_FLAGS_RELEASE}" )
+		endif()
+	elseif( ${PROJECT_NAME}_TYPE STREQUAL "MODULE_LIBRARY" )
+		set_target_properties( ${target_name} PROPERTIES LINK_FLAGS "${${PROJECT_NAME}_MODULE_LINKER_FLAGS}" )
+		if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
+			set_target_properties( ${target_name} PROPERTIES LINK_FLAGS_DEBUG "${${PROJECT_NAME}_MODULE_LINKER_FLAGS_DEBUG}" )
+		elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
+			set_target_properties( ${target_name} PROPERTIES LINK_FLAGS_RELEASE "${${PROJECT_NAME}_MODULE_LINKER_FLAGS_RELEASE}" )
+		endif()
+	elseif( ${PROJECT_NAME}_TYPE STREQUAL "EXECUTABLE" )
+		if ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Debug" )
+			set_target_properties( ${target_name} PROPERTIES LINK_FLAGS_DEBUG "${${PROJECT_NAME}_EXE_LINKER_FLAGS} ${${PROJECT_NAME}_EXE_LINKER_FLAGS_DEBUG}" )
+		elseif ( ${PROJECT_NAME}_BUILD_TYPE STREQUAL "Release" )
+			set_target_properties( ${target_name} PROPERTIES LINK_FLAGS_RELEASE "${${PROJECT_NAME}_EXE_LINKER_FLAGS} ${${PROJECT_NAME}_EXE_LINKER_FLAGS_RELEASE}" )
+		endif()
+	endif()
+endmacro (WkTargetSetProperties )
+
+
+#
+# WkExportConfig ( target1 [ target2 [...]] )
+#
+macro (WkExportConfig target1 )

 	#
 	# Generating configuration cmake file
 	#

-	WkGenConfig( )
+	WkGenConfig( ${target1} ${ARGN} )

 	#Linking source dependencies, and modifying config files
 	foreach (sdep ${${PROJECT_NAME}_SRCDEPENDS} )
@@ -460,29 +601,68 @@
 	endforeach()

 	WkFinConfig()
-
-CMAKE_POLICY(POP)
-endmacro (WkBuild)
-
-#Sets specific compile and link flags the build ( override default target flags from wkcmake )
-#build_type can be either "Debug, "Release", or "All"
-#WkBuildOptions ( build_type compile_flags [link_flags] )
-macro (WkBuildOptions build_type compile_flags )
-    WkTargetBuildOptions( "${PROJECT_NAME}" "${build_type}" "${compile_flags}" "${ARGV2}")
-endmacro (WkBuildOptions)
-
-
-#macro (WkBuild project_type [load_type])
-#TODO for backward compat. must call :
-
-#WkTarget generates a target for the current project.
-#with same Language as Project and implicit dependency of main build target (to check if always doable)
-macro (WkTarget target_name include_dir source_dir project_type [load_type])
-CMAKE_POLICY(PUSH)
-CMAKE_POLICY(VERSION 2.6)
-#TODO
-CMAKE_POLICY(POP)
-endmacro(WkTarget)
+
+endmacro (WkExportConfig)
+
+
+#
+# WkTargetFormat( target_name files)
+#
+macro (WkTargetFormat target_name )
+	#TODO : automatic detectino on windows ( preinstalled with wkcmake... )
+	FIND_PACKAGE(WKCMAKE_AStyle)
+	IF ( WKCMAKE_AStyle_FOUND )
+		option (${PROJECT_NAME}_${target_name}_CODE_FORMAT "Enable Code Formatting" OFF)
+		IF ( ${PROJECT_NAME}_${target_name}_CODE_FORMAT )
+			set(${PROJECT_NAME}_${target_name}_CODE_FORMAT_STYLE "ansi" CACHE STRING "Format Style for AStyle")
+			#converting to system path ( needed because command line call later )
+			set(FILES_NATIVE "")
+			foreach (f ${ARGN} )
+				FILE(TO_NATIVE_PATH ${f} f_nat)
+				SET(FILES_NATIVE ${FILES_NATIVE} ${f_nat})
+			endforeach(f)
+			WkWhitespaceSplit( FILES_NATIVE FILES_PARAM_NATIVE )
+			#message ( "Sources :  ${FILES_PARAM_NATIVE} ${FILES_PARAM_NATIVE}" )
+			set ( cmdline " ${WKCMAKE_AStyle_EXECUTABLE} --style=${${PROJECT_NAME}_${target_name}_CODE_FORMAT_STYLE} ${FILES_PARAM_NATIVE}" )
+			#message ( "CMD : ${cmdline} " )
+			#message ( "WORKING_DIR : ${PROJECT_SOURCE_DIR} " )
+			IF ( WIN32 )
+				ADD_CUSTOM_TARGET(${PROJECT_NAME}_${target_name}_format ALL cmd /c ${cmdline} WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM )
+			ELSE ( WIN32 )
+				ADD_CUSTOM_TARGET(${PROJECT_NAME}_${target_name}_format ALL sh -c ${cmdline} WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM )
+			ENDIF ( WIN32 )
+		ENDIF ( ${PROJECT_NAME}_${target_name}_CODE_FORMAT )
+	ENDIF ( WKCMAKE_AStyle_FOUND )
+endmacro (WkTargetFormat)
+
+#
+# WkTargetCppCheck( target_name )
+#
+macro (WkTargetCppCheck target_name )
+
+	#code analysis by target introspection -> needs to be done after target definition ( as here )
+	FIND_PACKAGE(WKCMAKE_Cppcheck)
+	IF ( WKCMAKE_Cppcheck_FOUND)
+		option ( ${PROJECT_NAME}_${target_name}_CODE_ANALYSIS "Enable Code Analysis" OFF)
+		IF ( ${PROJECT_NAME}_${target_name}_CODE_ANALYSIS )
+			Add_WKCMAKE_Cppcheck_target(${target_name}_cppcheck ${target_name} "${PROJECT_NAME}-${target_name}-cppcheck.xml")
+		ENDIF ( ${PROJECT_NAME}_${target_name}_CODE_ANALYSIS )
+	ENDIF ( WKCMAKE_Cppcheck_FOUND)
+
+	#setting up dependencies between formatting and code analysis target
+	if ( WKCMAKE_Cppcheck_FOUND AND ${PROJECT_NAME}_${target_name}_CODE_ANALYSIS )
+		add_dependencies(${target_name} ${target_name}_cppcheck)
+		if( WKCMAKE_AStyle_FOUND AND ${PROJECT_NAME}_CODE_FORMAT )
+			add_dependencies(${target_name}_cppcheck ${PROJECT_NAME}_format)
+		endif( WKCMAKE_AStyle_FOUND AND ${PROJECT_NAME}_CODE_FORMAT )
+	else ( WKCMAKE_Cppcheck_FOUND AND ${PROJECT_NAME}_${target_name}_CODE_ANALYSIS )
+		if( WKCMAKE_AStyle_FOUND AND ${PROJECT_NAME}_CODE_FORMAT )
+			add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_format)
+		endif( WKCMAKE_AStyle_FOUND AND ${PROJECT_NAME}_CODE_FORMAT )
+	endif( WKCMAKE_Cppcheck_FOUND AND ${PROJECT_NAME}_${target_name}_CODE_ANALYSIS )
+
+
+endmacro (WkTargetCppCheck)

 #
 # WkExtData( [ datafile1 [ datafile2 [ ... ] ] ] )


enh: Add _s.lib suffix to static libraries on Windows [CMake]

--- CMake/Modules/mirtkAddLibrary.cmake
+++ CMake/Modules/mirtkAddLibrary.cmake
@@ -70,8 +70,14 @@
            $<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}>
     PRIVATE ${PROJECT_CODE_DIR}
   )
-  if (TARGET_AUTO_REGISTER AND BUILD_SHARED_LIBS)
-    target_compile_definitions(${target_uid} PRIVATE MIRTK_AUTO_REGISTER)
+  if (BUILD_SHARED_LIBS)
+    if (TARGET_AUTO_REGISTER)
+      target_compile_definitions(${target_uid} PRIVATE MIRTK_AUTO_REGISTER)
+    endif ()
+  else ()
+    if (WIN32)
+      set_target_properties(${target_uid} PROPERTIES SUFFIX "_s.lib")
+    endif ()
   endif ()
   # VTK 7.0.0 adds its CMake modules directory to CMAKE_MODULE_PATH
   # and this directory contains a GenerateExportHeader.cmake module


Fix curl fallback for downloading files (#1904)

The curl file download fallback option was not saving files as
the correct filename. Instead, it used the -O option, which
saved the files using the remote's name for the file! This
was problematic for files downloaded using specification of git
sha.

--- Code/cmake/Modules/RDKitUtils.cmake
+++ Code/cmake/Modules/RDKitUtils.cmake
@@ -187,7 +187,7 @@
       if(WIN32)
         execute_process(COMMAND powershell -Command "(New-Object Net.WebClient).DownloadFile('${url}', '${target}')")
       else(WIN32)
-        execute_process(COMMAND curl -L -O "${url}" WORKING_DIRECTORY ${targetDir})
+        execute_process(COMMAND curl -L "${url}" -o ${target} WORKING_DIRECTORY ${targetDir})
       endif(WIN32)
     endif()
     if (NOT EXISTS ${target})


Don't link against asan, just preload it

--- CMake/clang.cmake
+++ CMake/clang.cmake
@@ -36,8 +36,8 @@

 if(ENABLE_ADDRESS_SANITIZER)
   set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
-  set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address -lasan")
-  set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address -lasan")
+  set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
+  set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
 endif(ENABLE_ADDRESS_SANITIZER)

 CHECK_CXX_COMPILER_FLAG("-Werror=missing-override" COMPILER_HAS_MISSING_OVERRIDE)


refs #6566 ignore some compiler warnings from third party stuff

--- CTestCustom.cmake
+++ CTestCustom.cmake
@@ -231,8 +231,11 @@
   # don't complain about clang missing warnings from xz code
   "clang: warning: unknown warning option"
   # don't complain about warnings in jemalloc source
-  "jemalloc-3.3.0/src"
+  "jemalloc/src"
   "jemalloc/internal"
+  # don't complain about valgrind headers leaving things unused
+  "valgrind/valgrind.h"
+  "valgrind/memcheck.h"
   # don't complain about ranlib or libtool on empty archive
   "has no symbols"
   "the table of contents is empty"


[t:4871] don't run upgrade_test_simple with valgrind

git-svn-id: b5c078ec0b4d3a50497e9dd3081db18a5b4f16e5@43633 c7de825b-a66e-492c-adef-691d508d4ae1

--- CTestCustom.cmake
+++ CTestCustom.cmake
@@ -44,6 +44,7 @@
   try-leak-reachable
   try-leak-uninit
   drd_test_4015.tdb
+  upgrade_test_simple
   )

 ## tests that are supposed to crash will generate memcheck failures


BUG: To perform ExperimentalUpload, EXTENSION_SUPERBUILD_BINARY_DIR needs to be defined. It was not defined anymore since we had removed include(Slicer_USE_FILE)

--- SuperBuild.cmake
+++ SuperBuild.cmake
@@ -215,6 +215,7 @@
      ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS}
      ${COMMON_EXTERNAL_PROJECT_ARGS}
     -DEXECUTABLES_ONLY:BOOL=${EXECUTABLES_ONLY}
+    -DEXTENSION_SUPERBUILD_BINARY_DIR:PATH=${CMAKE_CURRENT_BINARY_DIR}
 )

 ## Force rebuilding of the main subproject every time building from super structure


cmake: rework cmocka build process

cmake: rework cmocka build process

Rather than wrapping around cmocka's existing cmake, simply inherit
the build setup/variables from the waffle project and build a simple
cmocka static library.
This way we'll no longer need to add the custom commands for build
and we'll be able to easily handle mingw-w64 and msvc build :)

To make things even better this speeds up the configure/build process.

Patch is largely written by Nils Gladitz, ngladitz on #cmake
Signed-off-by: Emil Velikov <4c996f2f093ddd0585a556460b4cc3ba555546ef@gmail.com>
Reviewed-by: Chad Versace <a557f7f75bf28dc19ac99107f5cc7cd6b3fbdb1a@linux.intel.com>

--- cmake/Modules/WaffleCMocka.cmake
+++ cmake/Modules/WaffleCMocka.cmake
@@ -24,60 +24,10 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 set(cmocka_source_dir ${CMAKE_SOURCE_DIR}/third_party/cmocka)
-set(cmocka_build_dir ${CMAKE_BINARY_DIR}/third_party/cmocka/build)
-set(cmocka_cmake_output_file ${cmocka_build_dir}/waffle-cmake.log)
-set(cmocka_cmake_error_file ${cmocka_build_dir}/waffle-cmake.err)
-set(cmocka_cmake_command "cd \"${cmocka_build_dir}\" && cmake -G\"${CMAKE_GENERATOR}\" -DCMAKE_C_COMPILER=\"${CMAKE_C_COMPILER}\" \"${cmocka_source_dir}\"")

-if(waffle_on_linux)
-    set(cmocka_library_location ${cmocka_build_dir}/src/libcmocka.so)
-elseif(waffle_on_mac)
-    set(cmocka_library_location ${cmocka_build_dir}/src/libcmocka.dylib)
-endif()
-
-include_directories(${cmocka_source_dir}/include)
-link_directories(${cmocka_build_dir}/src)
-
-add_library(cmocka SHARED IMPORTED)
-set_target_properties(cmocka
-    PROPERTIES
-        IMPORTED_LOCATION ${cmocka_library_location}
-)
-add_dependencies(cmocka cmocka-build)
-add_custom_command(
-    OUTPUT ${cmocka_library_location}
-    WORKING_DIRECTORY ${cmocka_build_dir}
-    COMMAND cmake --build .
+list(APPEND CMOCKA_SOURCES
+       ${cmocka_source_dir}/src/cmocka.c
 )

-add_custom_target(cmocka-build
-    DEPENDS ${cmocka_library_location}
-)
-add_custom_target(cmocka-clean
-    WORKING_DIRECTORY ${cmocka_build_dir}
-    COMMAND cmake --build . --target clean
-)
-
-# Configure CMocka.
-if(NOT EXISTS ${cmocka_build_dir}/CMakeCache.txt)
-    file(MAKE_DIRECTORY ${cmocka_build_dir})
-    message(STATUS "Configuring subproject third_party/cmocka")
-    message(STATUS "${cmocka_cmake_command}")
-    execute_process(
-        COMMAND sh -c ${cmocka_cmake_command}
-        RESULT_VARIABLE cmocka_cmake_result
-        OUTPUT_FILE ${cmocka_cmake_output_file}
-        ERROR_FILE ${cmocka_cmake_error_file}
-    )
-    if(NOT ${cmocka_cmake_result} EQUAL 0)
-        if(EXISTS ${cmocka_cmake_error_file})
-            message(STATUS "Error messages from subproject third_party/cmocka:")
-            message(STATUS)
-            execute_process(COMMAND cat ${cmocka_cmake_error_file})
-        endif()
-        message(STATUS "See following files for details on cmocka configuration failure::")
-        message(STATUS "  ${cmocka_cmake_output_file}")
-        message(STATUS "  ${cmocka_cmake_error_file}")
-        message(FATAL_ERROR "Failed to configure subproject third_party/cmocka")
-    endif()
-endif()
+add_library(cmocka STATIC ${cmocka_source_dir}/src/cmocka.c)
+target_include_directories(cmocka PUBLIC ${cmocka_source_dir}/include)


Raspberry Pi: Fix CURL

Raspberry Pi: Fix CURL

--- cmake/projects/CURL/hunter.cmake
+++ cmake/projects/CURL/hunter.cmake
@@ -43,7 +43,7 @@
     3ac2684e3274c17ca209731e121e9a0acc79e4a5
 )

-if (ANDROID OR IOS)
+if (ANDROID OR IOS OR RASPBERRY_PI)
   set(_curl_cmake_args
       HAVE_GLIBC_STRERROR_R=1
       HAVE_GLIBC_STRERROR_R__TRYRUN_OUTPUT=""


Install all project targets before running doxygen

--- DoxygenRule.cmake
+++ DoxygenRule.cmake
@@ -90,8 +90,7 @@
 endif()

 add_custom_target(doxygen_install_${PROJECT_NAME}
-  ${CMAKE_COMMAND}
-  -P ${PROJECT_BINARY_DIR}/${PROJECT_INCLUDE_NAME}/cmake_install.cmake
+  ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/cmake_install.cmake
   DEPENDS ${INSTALL_DEPENDS})
 set_target_properties(doxygen_install_${PROJECT_NAME} PROPERTIES
   EXCLUDE_FROM_DEFAULT_BUILD ON FOLDER "doxygen")


Fix FindPoppler for all varieties of system package / user-compiled library.

--- FindPoppler.cmake
+++ FindPoppler.cmake
@@ -1,22 +1,29 @@
-# - Try to find Poppler and specified components (Qt4, Qt5)
-# Once done this will define
+# - Try to find Poppler and specified components: {cpp, Qt4, Qt5}
+# Once done this will define:
 #
 #  POPPLER_FOUND - system has Poppler and specified components
 #  POPPLER_INCLUDE_DIRS - The include directories for Poppler headers
 #  POPPLER_LIBRARIES - Link these to use Poppler
 #  POPPLER_NEEDS_FONTCONFIG - A boolean indicating if libpoppler depends on libfontconfig
-#  POPPLER_HAS_XPDF - A boolean indicating if Poppler XPDF headers are available
-#  POPPLER_XPDF_INCLUDE_DIR - the include directory for Poppler XPDF headers
+#  POPPLER_HAS_XPDF - A boolean indicating if libpoppler headers are available
+#  POPPLER_INCLUDE_DIR - the include directory for libpoppler XPDF headers
 #
 # Redistribution and use of this file is allowed according to the terms of the
 # MIT license. For details see the file COPYING-CMAKE-MODULES.

 if( POPPLER_LIBRARIES )
    # in cache already
-   SET( Poppler_FIND_QUIETLY TRUE )
+   set( Poppler_FIND_QUIETLY TRUE )
 endif( POPPLER_LIBRARIES )

 # Check which components we need to find
+list(FIND Poppler_FIND_COMPONENTS "cpp" FIND_POS)
+if(${FIND_POS} EQUAL -1)
+  set(FIND_CPP FALSE)
+else()
+  set(FIND_CPP TRUE)
+endif()
+
 list(FIND Poppler_FIND_COMPONENTS "Qt4" FIND_POS)
 if(${FIND_POS} EQUAL -1)
   set(FIND_QT4 FALSE)
@@ -31,95 +38,131 @@
   set(FIND_QT5 TRUE)
 endif()

+# Default values
+set(POPPLER_FOUND FALSE)
+set(POPPLER_INCLUDE_DIRS)
+set(POPPLER_LIBRARIES)
+set(POPPLER_REQUIRED "POPPLER_LIBRARY")
+
 # use pkg-config to get the directories and then use these values
-# in the FIND_PATH() and FIND_LIBRARY() calls
+# in the find_path() and find_library() calls
 if( NOT WIN32 )
   find_package(PkgConfig)

   pkg_check_modules(POPPLER_PKG QUIET poppler)
-if( FIND_QT4 )
-  pkg_check_modules(POPPLER_QT_PKG QUIET poppler-qt4)
-endif()
-if( FIND_QT5 )
-  pkg_check_modules(POPPLER_QT_PKG QUIET poppler-qt5)
-endif()
+  if( FIND_CPP )
+    pkg_check_modules(POPPLER_CPP_PKG QUIET poppler-cpp)
+  endif()
+  if( FIND_QT4 )
+    pkg_check_modules(POPPLER_QT4_PKG QUIET poppler-qt4)
+  endif()
+  if( FIND_QT5 )
+    pkg_check_modules(POPPLER_QT5_PKG QUIET poppler-qt5)
+  endif()
 endif( NOT WIN32 )

-# Check for Poppler XPDF headers (optional)
-FIND_PATH(POPPLER_XPDF_INCLUDE_DIR NAMES poppler-config.h PATH_SUFFIXES poppler)
-IF( NOT(POPPLER_XPDF_INCLUDE_DIR) )
-  IF( NOT Poppler_FIND_QUIETLY )
-    MESSAGE( STATUS "Could not find poppler-config.h, disabling support for Xpdf headers." )
-  ENDIF( NOT Poppler_FIND_QUIETLY )
-  SET( POPPLER_HAS_XPDF false )
-ELSE( NOT(POPPLER_XPDF_INCLUDE_DIR) )
-  SET( POPPLER_HAS_XPDF true )
-ENDIF( NOT(POPPLER_XPDF_INCLUDE_DIR) )
+# Check for Poppler headers (optional)
+find_path( POPPLER_INCLUDE_DIR NAMES poppler-config.h PATH_SUFFIXES poppler )
+if( NOT( POPPLER_INCLUDE_DIR ) )
+  if( NOT Poppler_FIND_QUIETLY )
+    message( STATUS "Could not find poppler-config.h, recompile Poppler with "
+                    "ENABLE_XPDF_HEADERS to link against libpoppler directly." )
+  endif()
+  set( POPPLER_HAS_XPDF FALSE )
+else()
+  set( POPPLER_HAS_XPDF TRUE )
+  list(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_INCLUDE_DIR})
+endif()

-# Find Poppler headers
-FIND_PATH(POPPLER_INCLUDE_DIR NAMES poppler-version.h PATH_SUFFIXES cpp poppler/cpp)
+# Find libpoppler (Required)
+find_library(POPPLER_LIBRARY NAMES poppler ${POPPLER_CPP_PKG_LIBRARIES})
+if( NOT(POPPLER_LIBRARY) )
+  if( NOT Poppler_FIND_QUIETLY )
+    message(STATUS "Could not find libpoppler." )
+  endif( NOT Poppler_FIND_QUIETLY )
+else( NOT(POPPLER_LIBRARY) )
+  list(APPEND POPPLER_LIBRARIES ${POPPLER_LIBRARY})

-# Find libpoppler, libpoppler-qt4 and associated header files (Required)
-FIND_LIBRARY(POPPLER_LIBRARY NAMES poppler ${POPPLER_PKG_LIBRARIES})
-IF ( NOT(POPPLER_LIBRARY) )
-  IF ( NOT Poppler_FIND_QUIETLY )
-    MESSAGE(STATUS "Could not find libpoppler." )
-  ENDIF ( NOT Poppler_FIND_QUIETLY )
-ELSE( NOT(POPPLER_LIBRARY) )
   # Scan poppler libraries for dependencies on Fontconfig
-  INCLUDE(GetPrerequisites)
-  MARK_AS_ADVANCED(gp_cmd)
+  include(GetPrerequisites)
+  mark_as_advanced(gp_cmd)
   GET_PREREQUISITES("${POPPLER_LIBRARY}" POPPLER_PREREQS 1 0 "" "")
-  IF ("${POPPLER_PREREQS}" MATCHES "fontconfig")
-    SET(POPPLER_NEEDS_FONTCONFIG TRUE)
-  ELSE ()
-    SET(POPPLER_NEEDS_FONTCONFIG FALSE)
-  ENDIF ()
+  if("${POPPLER_PREREQS}" MATCHES "fontconfig")
+    set(POPPLER_NEEDS_FONTCONFIG TRUE)
+  else()
+    set(POPPLER_NEEDS_FONTCONFIG FALSE)
+  endif()
+
+  # cpp Component
+  if( FIND_CPP )
+    list(APPEND POPPLER_REQUIRED POPPLER_CPP_INCLUDE_DIR POPPLER_CPP_LIBRARY)
+    find_path( POPPLER_CPP_INCLUDE_DIR NAMES poppler-version.h
+               PATH_SUFFIXES cpp poppler/cpp )
+    if( NOT(POPPLER_CPP_INCLUDE_DIR) )
+      if( NOT Poppler_FIND_QUIETLY )
+        message(STATUS "Could not find Poppler cpp wrapper headers." )
+      endif( NOT Poppler_FIND_QUIETLY )
+    else()
+      list(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_CPP_INCLUDE_DIR})
+    endif()
+    find_library( POPPLER_CPP_LIBRARY NAMES poppler-cpp ${POPPLER_CPP_PKG_LIBRARIES} )
+    if( NOT(POPPLER_CPP_LIBRARY) )
+      if( NOT Poppler_FIND_QUIETLY )
+        message(STATUS "Could not find libpoppler-cpp." )
+      endif( NOT Poppler_FIND_QUIETLY )
+    else()
+      list(APPEND POPPLER_LIBRARIES ${POPPLER_CPP_LIBRARY})
+    endif()
+  endif()

   # Qt4 Component
-  IF( FIND_QT4 )
-    FIND_PATH(POPPLER_QT4_INCLUDE_DIR NAMES poppler-qt4.h poppler-link.h
+  if( FIND_QT4 )
+    list(APPEND POPPLER_REQUIRED POPPLER_QT4_INCLUDE_DIR POPPLER_QT4_LIBRARY)
+    find_path(POPPLER_QT4_INCLUDE_DIR NAMES poppler-qt4.h poppler-link.h
               PATH_SUFFIXES qt4 poppler/qt4)
-    IF ( NOT(POPPLER_QT4_INCLUDE_DIR) )
-      IF ( NOT Poppler_FIND_QUIETLY )
-        MESSAGE(STATUS "Could not find Poppler-Qt4 headers." )
-      ENDIF ( NOT Poppler_FIND_QUIETLY )
-    ENDIF ()
-    FIND_LIBRARY(POPPLER_QT4_LIBRARY NAMES poppler-qt4 ${POPPLER_QT_PKG_LIBRARIES})
-    IF ( NOT(POPPLER_QT4_LIBRARY) )
-      IF ( NOT Poppler_FIND_QUIETLY )
-        MESSAGE(STATUS "Could not find libpoppler-qt4." )
-      ENDIF ( NOT Poppler_FIND_QUIETLY )
-    ENDIF ()
-  ENDIF()
+    if( NOT(POPPLER_QT4_INCLUDE_DIR) )
+      if( NOT Poppler_FIND_QUIETLY )
+        message(STATUS "Could not find Poppler-Qt4 headers." )
+      endif( NOT Poppler_FIND_QUIETLY )
+    else()
+      list(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_QT4_INCLUDE_DIR})
+    endif()
+    find_library(POPPLER_QT4_LIBRARY NAMES poppler-qt4 ${POPPLER_QT4_PKG_LIBRARIES})
+    if( NOT(POPPLER_QT4_LIBRARY) )
+      if( NOT Poppler_FIND_QUIETLY )
+        message(STATUS "Could not find libpoppler-qt4." )
+      endif( NOT Poppler_FIND_QUIETLY )
+    else()
+      list(APPEND POPPLER_LIBRARIES ${POPPLER_QT4_LIBRARY})
+    endif()
+  endif()

   # Qt5 Component
-  IF( FIND_QT5 )
-    FIND_PATH(POPPLER_QT5_INCLUDE_DIR NAMES poppler-qt5.h poppler-link.h
+  if( FIND_QT5 )
+    list(APPEND POPPLER_REQUIRED POPPLER_QT5_INCLUDE_DIR POPPLER_QT5_LIBRARY)
+    find_path(POPPLER_QT5_INCLUDE_DIR NAMES poppler-qt5.h poppler-link.h
               PATH_SUFFIXES qt5 poppler/qt5)
-    IF ( NOT(POPPLER_QT5_INCLUDE_DIR) )
-      IF ( NOT Poppler_FIND_QUIETLY )
-        MESSAGE(STATUS "Could not find Poppler-Qt5 headers." )
-      ENDIF ( NOT Poppler_FIND_QUIETLY )
-    ENDIF ()
-    FIND_LIBRARY(POPPLER_QT5_LIBRARY NAMES poppler-qt5 ${POPPLER_QT_PKG_LIBRARIES})
-    IF ( NOT(POPPLER_QT5_LIBRARY) )
-      IF ( NOT Poppler_FIND_QUIETLY )
-        MESSAGE(STATUS "Could not find libpoppler-qt5." )
-      ENDIF ( NOT Poppler_FIND_QUIETLY )
-    ENDIF ()
-  ENDIF()
-ENDIF ( NOT(POPPLER_LIBRARY) )
-
-LIST(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_INCLUDE_DIR}
-     ${POPPLER_QT4_INCLUDE_DIR} ${POPPLER_QT5_INCLUDE_DIR})
-
-LIST(APPEND POPPLER_LIBRARIES ${POPPLER_LIBRARY}
-     ${POPPLER_QT4_LIBRARY} ${POPPLER_QT5_LIBRARY})
+    if( NOT(POPPLER_QT5_INCLUDE_DIR) )
+      if( NOT Poppler_FIND_QUIETLY )
+        message( STATUS "Could not find Poppler-Qt5 headers." )
+      endif( NOT Poppler_FIND_QUIETLY )
+    else()
+      list(APPEND POPPLER_INCLUDE_DIRS ${POPPLER_QT5_INCLUDE_DIR})
+    endif()
+    find_library(POPPLER_QT5_LIBRARY NAMES poppler-qt5 ${POPPLER_QT5_PKG_LIBRARIES})
+    if( NOT(POPPLER_QT5_LIBRARY) )
+      if( NOT Poppler_FIND_QUIETLY )
+        message(STATUS "Could not find libpoppler-qt5." )
+      endif( NOT Poppler_FIND_QUIETLY )
+    else()
+      list(APPEND POPPLER_LIBRARIES ${POPPLER_QT5_LIBRARY})
+    endif()
+  endif()
+endif( NOT(POPPLER_LIBRARY) )

 include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Poppler DEFAULT_MSG POPPLER_LIBRARIES POPPLER_INCLUDE_DIRS)
+find_package_handle_standard_args(Poppler DEFAULT_MSG ${POPPLER_REQUIRED})

-MARK_AS_ADVANCED(POPPLER_XPDF_INCLUDE_DIR POPPLER_INCLUDE_DIR
-                 POPPLER_QT4_INCLUDE_DIR POPPLER_QT5_INCLUDE_DIR
-                 POPPLER_LIBRARIES POPPLER_QT4_LIBRARY POPPLER_QT5_LIBRARY)
+mark_as_advanced(POPPLER_CPP_INCLUDE_DIR POPPLER_QT4_INCLUDE_DIR
+                 POPPLER_QT5_INCLUDE_DIR POPPLER_LIBRARIES POPPLER_CPP_LIBRARY
+                 POPPLER_QT4_LIBRARY POPPLER_QT5_LIBRARY)


COMP: Update KWStyle's version to avoid compile errors with C++23

--- Utilities/KWStyle/BuildKWStyle.cmake
+++ Utilities/KWStyle/BuildKWStyle.cmake
@@ -23,7 +23,7 @@
 if(NOT TARGET KWStyle)
 ExternalProject_add(KWStyle
   GIT_REPOSITORY "${git_protocol}://github.com/Kitware/KWStyle.git"
-  GIT_TAG 39aaf6cc9d56ae1cbf28f098ade3df1f58131c01
+  GIT_TAG 840d0f63174d6aa21089a0514ee1e733b98c0709
   UPDATE_COMMAND ""
   DOWNLOAD_DIR ${KWStyle_SOURCE_DIR}
   SOURCE_DIR ${KWStyle_SOURCE_DIR}


STYLE: Nightly Date Stamp

STYLE: Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 03)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   23)
+SET(KWSYS_DATE_STAMP_DAY   24)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 02)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   14)
+SET(KWSYS_DATE_STAMP_DAY   15)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 12)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   29)
+SET(KWSYS_DATE_STAMP_DAY   30)


STYLE: Nightly Date Stamp

STYLE: Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 02)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   06)
+SET(KWSYS_DATE_STAMP_DAY   07)


STYLE: Nightly Date Stamp

STYLE: Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 04)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   10)
+SET(KWSYS_DATE_STAMP_DAY   11)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 07)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   12)
+SET(KWSYS_DATE_STAMP_DAY   13)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 08)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   15)
+SET(KWSYS_DATE_STAMP_DAY   16)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 02)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   04)
+SET(KWSYS_DATE_STAMP_DAY   05)


STYLE: Nightly Date Stamp

STYLE: Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 06)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   26)
+SET(KWSYS_DATE_STAMP_DAY   27)


Bug fix: Regard a error prompt text of Visual Studio compiler output as a dependent header file during using add_style_check, but there is no error report during the process of generate Visual Studio project, then get a compile failure when executing style check.

--- utils/add_style_check.cmake
+++ utils/add_style_check.cmake
@@ -108,12 +108,18 @@
     INCLUDE_DIRS  ${include_dirs}
   )

-  # Strip the white characters and remove duplicate items.
+  # Strip white characters and assert the exist of each header file, then remove duplicate items.
   foreach(header_file ${raw_header_files})
     string(STRIP ${header_file} header_file)
-    set(header_files ${header_files} ${header_file})
+    if (NOT EXISTS ${header_file})
+      message(FATAL_ERROR "Can't find the header file: \"${header_file}\", function\
+      \"add_style_check\" find it is used by target \"${target_name}\"!")
+    else()
+      set(header_files ${header_files} ${header_file})
+    endif()
   endforeach()
   list(REMOVE_DUPLICATES header_files)
+
                 # message("header_files is ${header_files}") # Debug use.
   # Remove the files that under exclude directories or in exclude file list.
   set(files ${src_files} ${header_files})
@@ -247,9 +253,16 @@
   set(include_dir_flag "-I")
   set(list_header_files_flag "-MM")
   if ("${compiler_id}" STREQUAL "MSVC")
-    set(definition_flag "/D")
-    set(include_dir_flag "/I")
-    set(list_header_files_flag "/showIncludes")
+    if ("$ENV{INCLUDE}" STREQUAL "")
+      message(FATAL_ERROR "To use the function \"add_style_check\" with Visual C++, cmake must be\
+        run from a shell that can use the compiler cl from the command line, and the \"INCLUDE\"\
+        environment variable must be set correctly. To fix this problem, run cmake from the Visual \
+        Studio Command Prompt (vcvarsall.bat).")
+    else()
+      set(definition_flag "/D")
+      set(include_dir_flag "/I")
+      set(list_header_files_flag "/showIncludes")
+    endif()
   elseif (NOT "${compiler_id}" STREQUAL "GNU")
     message(FATAL_ERROR "Can't support your compiler now, only MSVC, GNU compiler can be used!")
   endif()


Fixed typo on posix builds

Fixed typo on posix builds

--- tools/cmake/PosixPostBuild.cmake
+++ tools/cmake/PosixPostBuild.cmake
@@ -8,7 +8,7 @@

 add_custom_target(DEPS)

-set_target_properties(DEPSs
+set_target_properties(DEPS
 	PROPERTIES
 	FOLDER "cmake_targets"
 )


cmake: Re-run cmake if submodule commits change or a submodule is deinit-ed

--- tools/cmake/git_submodules.cmake
+++ tools/cmake/git_submodules.cmake
@@ -41,6 +41,16 @@
       elseif(NOT "${status}" STREQUAL " ")
         message(WARNING "Git submodule ${submodule_path} is out of date. Run 'git submodule update --init --recursive' to fix.")
       endif()
+
+      # Force a re-run of cmake if the submodule's .git file changes or is changed (ie accidental deinit)
+      get_filename_component(submodule_abs_path ${submodule_path} ABSOLUTE BASE_DIR ${root_path})
+      set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${submodule_abs_path}/.git)
+      # same if the HEAD file in the submodule's directory changes (ie commit changes). This will at least prit the 'out of date' warning
+      set(submodule_head "${root_path}/.git/modules/${submodule_path}/HEAD")
+      if(EXISTS "${submodule_head}")
+        set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${submodule_head})
+      endif()
+
     endforeach()
   endfunction(git_submodule_check)


Workaround for a CTK bug: QuaZip external project library dir is not exposed

--- CMake/PackageDepends/MITK_CTK_Config.cmake
+++ CMake/PackageDepends/MITK_CTK_Config.cmake
@@ -10,3 +10,7 @@
   include(${CTK_DIR}/qRestAPI-build/qRestAPIConfig.cmake)
   link_directories(${qRestAPI_LIBRARY_DIRS})
 endif()
+if(EXISTS "${CTK_DIR}/QuaZip-build/QuaZipConfig.cmake")
+  include(${CTK_DIR}/QuaZip-build/QuaZipConfig.cmake)
+  link_directories(${QUAZIP_LIBRARY_DIRS})
+endif()


Fixed tinyxml dependency

Fixed tinyxml dependency

--- CMakeModules/KrisLibraryDependencies.cmake
+++ CMakeModules/KrisLibraryDependencies.cmake
@@ -80,9 +80,9 @@
 FIND_PACKAGE(TinyXML)
 IF(TINYXML_FOUND)
   MESSAGE("TinyXML library found")
-  SET(KRISLIBRARY_DEFINITIONS ${KRISLIBRARY_DEFINITIONS} -DHAVE_TIXML=1 -DTIXML_USE_STL)
+  SET(KRISLIBRARY_DEFINITIONS ${KRISLIBRARY_DEFINITIONS} -DHAVE_TINYXML=1 -DTIXML_USE_STL)
   SET(KRISLIBRARY_INCLUDE_DIRS ${KRISLIBRARY_INCLUDE_DIRS} ${TINYXML_INCLUDE_DIR})
-  SET(KRISLIBRARY_LIBRARIES ${KRISLIBRARY_LIBRARIES} ${TINYXML_LIBRARY})
+  SET(KRISLIBRARY_LIBRARIES ${KRISLIBRARY_LIBRARIES} ${TINYXML_LIBRARIES})
 ELSE(TINYXML_FOUND)
   MESSAGE("TinyXML library not found, setting HAVE_TINYXML=0")
 ENDIF(TINYXML_FOUND)
@@ -104,7 +104,7 @@
 ENDIF(ASSIMP_FOUND)

 IF(WIN32)
-  SET(KRISLIBRARY_DEFINITIONS ${KRISLIBRARY_DEFINITIONS} -DNOMINMAX)
+  SET(KRISLIBRARY_DEFINITIONS ${KRISLIBRARY_DEFINITIONS} -DNOMINMAX -DGLUI_NO_LIB_PRAGMA)
 ENDIF(WIN32)

 SET(KRISLIBRARY_INCLUDE_DIRS ${KRISLIBRARY_INCLUDE_DIRS}


update documentation and a small correction

--- lib/OpenCogFunctions.cmake
+++ lib/OpenCogFunctions.cmake
@@ -1,15 +1,35 @@
-# 1. The name of the directory is the name of the module
+# Copyright (C) 2016 OpenCog Foundation
+#
+# 1. The name of the directory and the name is the name of the module
 # 2. There must be a .scm file in the same directory as the module. This file
 #    on installation will be copied one directory above its current directory.
-# Types of scm modules
-# 1. Modules that doen't have any c++ code like the nlp modules can
-#    exist in their separte directory and the directory structure implies the
-#    module structure.
-# 2. If there is a c++ code then the scheme moduel will be under `scm/`
+#
+# Types of scm module directory structures
+# 1. Modules that doen't have any c++ code modules can exist in their separate
+#    directory. Examples,
+#    * `/repo-name/opencog/some-module/some-module.scm` is imported by
+#      `(use-modules (opencog some-module ))` if `some-module.scm` has an
+#      expression `(define-module (opencog some-module))`
+#    * `/repo-name/opencog/some-module/sub-module/sub-module.scm` is imported
+#      by `(use-modules (opencog some-module sub-module))` if `sub-module.scm`
+#      has an expression `(define-module (opencog some-module sub-module))`
+# 2. If there is a c++ code then the scheme module should be under `scm/`
 #    directory. And on installation or symlinking the `scm/` directory is
-#    escaped.
-# 3. The same logic would apply for python
-# 4. Everything should be explicit
+#    escaped. If there are more than one `scm/` directories only the first in
+#    the hierarchy is escaped. As the need arises multiple `scm/` directory
+#    escpaes maybe be added in the future. Examples,
+#    * `/repo-name/opencog/some-module/scm/some-module.scm` is imported by
+#      `(use-modules (opencog some-module ))` if `some-module.scm` has an
+#      expression `(define-module (opencog some-module))`
+#    * `/repo-name/opencog/some-module/scm/sub-module/sub-module.scm` is
+#      imported by `(use-modules (opencog some-module sub-module))` if
+#      `sub-module.scm` has an expression `(define-module (opencog some-module
+#      sub-module))`
+
+# References:
+# https://www.gnu.org/software/guile/manual/guile.html#Modules-and-the-File-System
+# https://www.gnu.org/software/guile/manual/guile.html#Creating-Guile-Modules
+

 FUNCTION(ADD_GUILE_MODULE SCHEME_FILE)
     FOREACH(FILE_NAME ${ARGV})
@@ -21,8 +41,10 @@
         ENDIF()
         # MODULE_FILE: The name of the file that defines the module. It has
         #   the same name as the directory it is in, or the name of the parent
-        #   directory of current directory if it is in a folder named 'scm'
-        #   and used to define the module.
+        #   directory of current directory if it is in a folder named 'scm'.
+        #   In addition this file shoule have a define-module expression
+        #   for it be importable, as per guile's specification. See reference
+        #   links above.
         SET(MODULE_FILE ${FILE_NAME})

         # Check if the file exists
@@ -67,7 +89,7 @@
         # Also configure for install.
         IF ("${MODULE_NAME}.scm" STREQUAL "${MODULE_FILE}")
             EXECUTE_PROCESS(
-                COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/opencog/scm/${MODULE_FILE_DIR_PATH}
+                COMMAND ${CMAKE_COMMAND} -E make_directory ${GUILE_SYMLINK_DIR}/${MODULE_FILE_DIR_PATH}
                 COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILE}" "${GUILE_SYMLINK_DIR}/${MODULE_FILE_DIR_PATH}/${MODULE_FILE}"
             )
             INSTALL(FILES
@@ -76,7 +98,7 @@
             )
         ELSE()
             EXECUTE_PROCESS(
-                COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/opencog/scm/${MODULE_FILES_DIR_PATH}
+                COMMAND ${CMAKE_COMMAND} -E make_directory ${GUILE_SYMLINK_DIR}/${MODULE_FILES_DIR_PATH}
                 COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILE}" "${GUILE_SYMLINK_DIR}/${MODULE_FILES_DIR_PATH}/${MODULE_FILE}"
             )
             INSTALL (FILES


DOC: Update the SphinxExamples Remote Module.

Change-Id: I011a281306f90977f09be2200247a05225fe80b2

--- Modules/Remote/SphinxExamples.remote.cmake
+++ Modules/Remote/SphinxExamples.remote.cmake
@@ -1,7 +1,7 @@
 # Contact: Matt McCormick <matt.mccormick@kitware.com>
 itk_fetch_module(SphinxExamples
   "This module builds the examples found at http://itk.org/ITKExamples/"
-  GIT_REPOSITORY ${git_protocol}://itk.org/ITKExamples.git
-  # 2015-07-09
-  GIT_TAG 2bc08a52aa0437da776cc777157f25b7b525b46f
+  GIT_REPOSITORY http://itk.org/ITKExamples.git
+  # 2016-01-27
+  GIT_TAG 3dfb50ce56c79cbc3f889d402ce1a920c1663a0f
   )


Replaced "Win32" by "$(Platform)" to support x64 configuration

--- Source/VideoStreaming/VideoStreaming.cmake
+++ Source/VideoStreaming/VideoStreaming.cmake
@@ -87,7 +87,7 @@
   ENDIF()
   IF((${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" ) AND LINK_VP9)
     #To do, library name depends on the compiler setting, could be vpxmt.lib and vpxmtd also. Make sure the setting matches.
-    SET(LINK_VP9_LIBRARY optimized ${VP9_LIBRARY_DIR}\\Win32\\Release\\vpxmd.lib debug ${VP9_LIBRARY_DIR}\\Win32\\Debug\\vpxmdd.lib)
+    SET(LINK_VP9_LIBRARY optimized ${VP9_LIBRARY_DIR}\\$(Platform)\\Release\\vpxmd.lib debug ${VP9_LIBRARY_DIR}\\$(Platform)\\Debug\\vpxmdd.lib)
     SET(LINK_LIBS
       ${LINK_LIBS}
       ${LINK_VP9_LIBRARY}


Updated device with VideoEncoder improvements

--- cmake/Depthai/DepthaiDeviceSideConfig.cmake
+++ cmake/Depthai/DepthaiDeviceSideConfig.cmake
@@ -2,7 +2,7 @@
 set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

 # "full commit hash of device side binary"
-set(DEPTHAI_DEVICE_SIDE_COMMIT "b263e5292bdb58d776d84a1a7bc1382d116f3488")
+set(DEPTHAI_DEVICE_SIDE_COMMIT "b911488dc709f79c2de6abd6352fc45db45ab5cf")

 # "version if applicable"
 set(DEPTHAI_DEVICE_SIDE_VERSION "")


Fail to configure with mismatched versions of Python and its libraries

This is a very common problem that keeps hitting users and our own
builds in Jenkins. Failing to configure with an error message is the
best we can do to avoid runtime problems due to mismatched versions
of the Python interpreter and libraries.

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -474,6 +474,12 @@
       message(STATUS "TMVA: numpy not found for python ${PYTHON_EXECUTABLE}. Switching off tmva-pymva option")
       set(tmva-pymva OFF CACHE BOOL "Disabled because numpy not found (${tmva-pymva_description})" FORCE)
     endif()
+  endif()
+
+  if(NOT "${PYTHON_VERSION_STRING}" STREQUAL "${PYTHONLIBS_VERSION_STRING}")
+    message(FATAL_ERROR "Version mismatch between Python interpreter (${PYTHON_VERSION_STRING})"
+    " and libraries (${PYTHONLIBS_VERSION_STRING}).\nROOT cannot work with this configuration. "
+    "Please specify only PYTHON_EXECUTABLE to CMake with an absolute path to ensure matching versions are found.")
   endif()
 endif()


Transmit the variables  CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET to ExternalProjects (llvm, clang,...)

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -592,6 +592,8 @@
                -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
                -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
                -DCMAKE_CXX_FLAGS=${__cxxflags}
+               -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
+               -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
   )
   # We cannot call find_package(XROOTD) becuase the package is not yet built. So, we need to emulate what it defines....
   set(_LIBDIR_DEFAULT "lib")
@@ -644,6 +646,8 @@
                  -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
                  -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
                  -DLLVM_NOCLING=ON
+                 -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
+                 -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
       INSTALL_COMMAND ${CMAKE_COMMAND} -P <BINARY_DIR>/cmake_install.cmake
       LOG_INSTALL 1
     )
@@ -724,6 +728,8 @@
                -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
                -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
                -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
+               -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
+               -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
     INSTALL_COMMAND ${CMAKE_COMMAND} -P <BINARY_DIR>/cmake_install.cmake
     LOG_INSTALL 1
   )


Remove a couple patterns from the Boost header exclude list.  Some headers in these directories are needed indirectly.

--HG--
branch : v1-7

--- CMake/InstallDependencies.cmake
+++ CMake/InstallDependencies.cmake
@@ -141,14 +141,12 @@
 	  # headers (try to exclude things we don't need)
 	  install(DIRECTORY "${Boost_INCLUDE_DIR}/boost" DESTINATION "boost_${Boost_LIB_VERSION}"
 		PATTERN "accumulators" EXCLUDE
-		PATTERN "algorithm" EXCLUDE
 		PATTERN "archive" EXCLUDE
 		PATTERN "asio" EXCLUDE
 		PATTERN "assign" EXCLUDE
 		PATTERN "bimap" EXCLUDE
 		PATTERN "circular_buffer" EXCLUDE
 		PATTERN "compatibility" EXCLUDE
-		PATTERN "concept" EXCLUDE
 		PATTERN "concept_check" EXCLUDE
 		PATTERN "dynamic_bitset" EXCLUDE
 		PATTERN "filesystem" EXCLUDE


Fix install of dependencies (including Boost) into sdk area on OS X

--- CMake/InstallDependencies.cmake
+++ CMake/InstallDependencies.cmake
@@ -10,20 +10,9 @@
 #####################################################
 # Install dependencies
 #####################################################
-
-if (UNIX)
+if ((NOT APPLE) AND (NOT WIN32))
   return()
 endif()
-
-# determine if we have a common dependencies folder to install from.
-# this is not a fool-proof test, but it should be good enough.
-get_filename_component(OGRE_DEP1_DIR ${FREETYPE_INCLUDE_DIR}/../ ABSOLUTE)
-get_filename_component(OGRE_DEP2_DIR ${ZLIB_INCLUDE_DIR}/../ ABSOLUTE)
-if (OGRE_DEP1_DIR STREQUAL OGRE_DEP2_DIR)
-  set(OGRE_DEP_DIR ${OGRE_DEP1_DIR})
-else ()
-  return()
-endif ()

 option(OGRE_INSTALL_DEPENDENCIES "Install dependency libs needed for samples" TRUE)
 option(OGRE_COPY_DEPENDENCIES "Copy dependency libs to the build directory" TRUE)


Disable Python version warning when WRAP_PYTHON is disabled.

--- CMake/sitkLanguageOptions.cmake
+++ CMake/sitkLanguageOptions.cmake
@@ -81,11 +81,6 @@
 endif()

 if ( PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
-    AND PYTHON_VERSION_STRING VERSION_LESS 2.7 )
-  message( WARNING "Python version less than 2.7: \"${PYTHON_VERSION_STRING}\"." )
-endif()
-
-if ( PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
     AND (PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING) )
   set( WRAP_PYTHON_DEFAULT ${WRAP_DEFAULT} )
 else()
@@ -93,6 +88,10 @@
 endif()

 option( WRAP_PYTHON "Wrap Python" ${WRAP_PYTHON_DEFAULT} )
+
+if ( WRAP_PYTHON AND PYTHON_VERSION_STRING VERSION_LESS 2.7 )
+  message( WARNING "Python version less than 2.7: \"${PYTHON_VERSION_STRING}\"." )
+endif()

 if ( WRAP_PYTHON )
   list( APPEND SITK_LANGUAGES_VARS


cmake: use the ternary generator expressions supported since 3.8

Now that the supported CMake version is >=3.16, this code can be
simplified.

--- components/esptool_py/project_include.cmake
+++ components/esptool_py/project_include.cmake
@@ -323,43 +323,6 @@
     endif()
 endfunction()

-# Use this function to generate a ternary expression that will be evaluated.
-# - retexpr is the expression returned by the function
-# - condition is the expression evaluated to a boolean
-# - condtrue is the expression to evaluate if condition is true
-# - condfalse is the expression to evaluate if condition is false
-# This function can be summarized as:
-#   retexpr = condition ? condtrue : condfalse
-function(if_expr_generator retexpr condition condtrue condfalse)
-    # CMake version 3.8 and above provide a ternary operator for expression
-    # generator. For version under, we must simulate this behaviour
-    if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
-
-        # If condtrue is not empty, then we have to do something in case the
-        # condition is true. Generate the expression that will be used in that
-        # case
-        if(condtrue)
-            set(iftrue "$<${condition}:${condtrue}>")
-        endif()
-
-        # Same for condfalse. If it is empty, it is useless to create an
-        # expression that will be evaluated later
-        if(condfalse)
-            set(iffalse "$<$<NOT:${condition}>:${condfalse}>")
-        endif()
-
-        # Concatenate the previously generated expressions. If one of them was
-        # not initialized (because of empty condtrue/condfalse) it will be
-        # replaced by an empty string
-        set(${retexpr} "${iftrue}${iffalse}" PARENT_SCOPE)
-
-    else()
-        # CMake 3.8 and above implement what we want, making the expression
-        # simpler
-        set(${retexpr} "$<IF:${condition},${condtrue},${condfalse}>" PARENT_SCOPE)
-    endif()
-endfunction()
-

 function(esptool_py_flash_target target_name main_args sub_args)
     set(single_value OFFSET IMAGE) # template file to use to be able to
@@ -442,8 +405,7 @@
 encrypted-${target_name},NON_ENCRYPTED_IMAGES>>")

         # Prepare esptool arguments (--encrypt or --encrypt-files)
-        if_expr_generator(if_non_enc_expr ${has_non_encrypted_images}
-                          "" "--encrypt")
+        set(if_non_enc_expr "$<IF:${has_non_encrypted_images},,--encrypt>")
         set_target_properties(encrypted-${target_name} PROPERTIES SUB_ARGS
                              "${sub_args}; ${if_non_enc_expr}")

@@ -455,8 +417,7 @@

         # Put both lists together, use --encrypted-files if we do also have
         # plain images to flash
-        if_expr_generator(if_enc_expr ${has_non_encrypted_images}
-                          "--encrypt-files\n" "")
+        set(if_enc_expr "$<IF:${has_non_encrypted_images},--encrypt-files\n,>")
         set(flash_args_content "$<JOIN:$<TARGET_PROPERTY:\
 encrypted-${target_name},SUB_ARGS>, >\
 ${non_encrypted_files}\n\


Generate wrapper script in current binary directory.

	 Arbitrary binary we bundle in the package such 'assistant' may live in
	 system directories. So we no longer generate the wrapper script in
	 the same directory. This fix ticket #114 of urbi-lab.

	* build-aux/cmake/modules/GenLibLoader.cmake: Do that.

Signed-off-by: Nicolas Despres <abdeb541ca46f1651c9cc594d44e707056e73d5d@gostai.com>

--- build-aux/cmake/modules/GenLibLoader.cmake
+++ build-aux/cmake/modules/GenLibLoader.cmake
@@ -36,7 +36,7 @@
     get_target_property(binary_loc ${binary} LOCATION_${CMAKE_BUILD_TYPE})
     set(binary_name ${binary})
   else(TARGET ${binary})
-    set(binary_loc ${binary})
+    set(binary_loc ${CMAKE_CURRENT_BINARY_DIR})
     get_filename_component(binary_name ${binary} NAME)
   endif(TARGET ${binary})
   get_filename_component(binary_path ${binary_loc} PATH)


Update `deb` package dependencies.

Update `deb` package dependencies.

libssl1.0.0 (>= 1.0.1)
libjansson4 (>= 2.3.1)

--- build/cmake/Package/linux-deb-common.cmake
+++ build/cmake/Package/linux-deb-common.cmake
@@ -4,5 +4,5 @@
 set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
 set(CPACK_SYSTEM_NAME "linux-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
 set(CPACK_DEBIAN_PACKAGE_DEPENDS
-	"libc6 (>= 2.13-28), libgcc1 (>= 1:4.8.2-21~), libstdc++6 (>=4.8.2-21~), lsb-base (>= 3.2-13)"
-)+	"libc6 (>= 2.13-28), libgcc1 (>= 1:4.8.2-21~), libstdc++6 (>=4.8.2-21~), lsb-base (>= 3.2-13), libssl1.0.0 (>= 1.0.1), libjansson4 (>= 2.3.1)"
+)


- Fix minor issue borking up Windows builds

--- cmake/Modules/CMakeConvenience.cmake
+++ cmake/Modules/CMakeConvenience.cmake
@@ -4,10 +4,12 @@
     endif()

     # Sneaky sneaky
-    target_compile_options ( ${TARGET}
-        PRIVATE
-        -O2
-        )
+    if(EMSCRIPTEN)
+        target_compile_options ( ${TARGET}
+            PRIVATE
+            -O2
+            )
+    endif()
 #    if(EMSCRIPTEN)
 #        target_compile_options(${TARGET} PRIVATE
 #            -s USE_SDL=2


cmake: s/qjson/qcommandline/

cmake: s/qjson/qcommandline/

Signed-off-by: Corentin Chary <298d22bb5b8e08c296f77ec9e7162462cf47b8a1@iksaif.net>

--- cmake/modules/FindQCommandLine.cmake
+++ cmake/modules/FindQCommandLine.cmake
@@ -1,7 +1,7 @@
 # Find QCOMMANDLINE - Command line handling library for Qt
 #
 # This module defines
-#  QCOMMANDLINE_FOUND - whether the qsjon library was found
+#  QCOMMANDLINE_FOUND - whether the qcommand library was found
 #  QCOMMANDLINE_LIBRARIES - the qcommandline library
 #  QCOMMANDLINE_INCLUDE_DIR - the include path of the qcommandline library
 #


build: Fixed the Matlab find script on Windows

A typo had crept to the FindThirdPartyMatlab.cmake with the earlier
changes that made it fail at least on Windows. Fixed.

--- cmake-modules/FindThirdPartyMatlab.cmake
+++ cmake-modules/FindThirdPartyMatlab.cmake
@@ -28,11 +28,13 @@

 # Figure out the paths to libs and includes
 IF(Matlab_EXECUTABLE)
-
+	# MESSAGE(STATUS "Have Matlab_EXECUTABLE ${Matlab_EXECUTABLE}")
 	# Try relative to the executable path
 	GET_FILENAME_COMPONENT(Matlab_ROOT ${Matlab_EXECUTABLE} PATH)
 	IF(Matlab_ROOT)
-		SET(Matlab_ROOT, ${Matlab_ROOT}/../)
+		# MESSAGE(STATUS "Have Matlab_ROOT ${Matlab_ROOT}")
+		SET(Matlab_ROOT ${Matlab_ROOT}/../)
+		# MESSAGE(STATUS " -> ${Matlab_ROOT}")
 		FIND_PATH(Matlab_INCLUDE "mex.h" PATHS ${Matlab_ROOT}/extern/include ${Matlab_ROOT}/extern/include/extern)
 	ENDIF(Matlab_ROOT)

@@ -44,6 +46,7 @@
 	ENDIF((NOT Matlab_INCLUDE) AND UNIX)

 	IF(Matlab_INCLUDE)
+		# MESSAGE(STATUS "Have Matlab_INCLUDE ${Matlab_INCLUDE}")
 		IF(UNIX)
 			SET(Matlab_LIBRARIES mex mx eng)
 			IF(CMAKE_SIZEOF_VOID_P EQUAL 4)


Clang use c++17

Clang use c++17

--- cmake/platform/unix/compiler/Clang.cmake
+++ cmake/platform/unix/compiler/Clang.cmake
@@ -1,5 +1,6 @@
 message("-- using clang")

+add_compiler_flags(-std=c++17)
 add_compiler_flags(-Wno-keyword-compat -Wno-unused-command-line-argument)

 if( ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang )


Updated packet generator download url

Updated packet generator download url

--- cmake/modules/Build-packet-generator.cmake
+++ cmake/modules/Build-packet-generator.cmake
@@ -9,11 +9,14 @@
   ${IDL_INSTALL_DIR}/bin/packet_generator.exe
 )

+string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} HOST_SYSTEM_NAME_LOWER)
+string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} HOST_SYSTEM_PROCESSOR_LOWER)
+
 if(WIN32 OR MINGW)
-  set(DOWNLOAD_URL https://github.com/dev-osrose/IDL/releases/download/idl-latest/win64-packet_generator.zip)
+  set(DOWNLOAD_URL https://github.com/dev-osrose/IDL/releases/download/idl-latest/${HOST_SYSTEM_NAME_LOWER}-${HOST_SYSTEM_PROCESSOR_LOWER}-packet_generator.zip)
   set(EXEC_POSTFIX .exe)
 else()
-  set(DOWNLOAD_URL https://github.com/dev-osrose/IDL/releases/download/idl-latest/linux-packet_generator.tar.gz)
+  set(DOWNLOAD_URL https://github.com/dev-osrose/IDL/releases/download/idl-latest/${HOST_SYSTEM_NAME_LOWER}-${HOST_SYSTEM_PROCESSOR_LOWER}-packet_generator.tar.gz)
   set(EXEC_POSTFIX )
 endif()


fix typo

fix typo

--- cmakemodules/script_detect_unix_arch.cmake
+++ cmakemodules/script_detect_unix_arch.cmake
@@ -14,5 +14,5 @@
 if ("${CMAKE_MRPT_ARCH}" STREQUAL "x86_64" OR "${CMAKE_MRPT_ARCH}" STREQUAL "i686")
 	set(MRPT_ARCH_INTEL_COMPATIBLE 1)
 else()
-	set(MRPT_ARCH_INTEL_COMPATIBLE 1)
+	set(MRPT_ARCH_INTEL_COMPATIBLE 0)
 endif()


added cmake fix for bug in OpenCV 2.4.2

added cmake fix for bug in OpenCV 2.4.2

--- CMake/PackageDepends/MITK_OpenCV_Config.cmake
+++ CMake/PackageDepends/MITK_OpenCV_Config.cmake
@@ -1,9 +1,49 @@
+# bug in opencv 2.4.2 and mitk: if we have a submodule OpenCV_LIB_DIR_OPT and
+# OpenCV_LIB_DIR_DBG is cached when find_package is called
+# resulting in wrong windows output paths, e.g. C:\OpenCV\lib\Release\Release
+# removing last Release and Debug string manually to fix it
+if( OpenCV_LIB_DIR )
+
+  string(REPLACE "/" ";" OpenCV_LIB_DIR_OPT_LIST ${OpenCV_LIB_DIR_OPT})
+  set(OpenCV_LIB_DIR_OPT "")
+  foreach(folderPart ${OpenCV_LIB_DIR_OPT_LIST})
+    if(NOT folderPart MATCHES  "Release")
+    if(NOT OpenCV_LIB_DIR_OPT)
+      set(OpenCV_LIB_DIR_OPT "${folderPart}")
+    else()
+      set(OpenCV_LIB_DIR_OPT "${OpenCV_LIB_DIR_OPT}/${folderPart}")
+    endif()
+    endif()
+  endforeach()
+  set(OpenCV_LIB_DIR_DBG ${OpenCV_LIB_DIR_OPT})
+
+  string(REPLACE "/" ";" OpenCV_3RDPARTY_LIB_DIR_OPT_LIST ${OpenCV_3RDPARTY_LIB_DIR_OPT})
+  set(OpenCV_3RDPARTY_LIB_DIR_OPT "")
+  foreach(folderPart ${OpenCV_3RDPARTY_LIB_DIR_OPT_LIST})
+    if(NOT folderPart MATCHES  "Release")
+    if(NOT OpenCV_3RDPARTY_LIB_DIR_OPT)
+      set(OpenCV_3RDPARTY_LIB_DIR_OPT "${folderPart}")
+    else()
+      set(OpenCV_3RDPARTY_LIB_DIR_OPT "${OpenCV_3RDPARTY_LIB_DIR_OPT}/${folderPart}")
+    endif()
+    endif()
+  endforeach()
+  set(OpenCV_3RDPARTY_LIB_DIR_DBG ${OpenCV_3RDPARTY_LIB_DIR_OPT})
+
+  #message("OpenCV_LIB_DIR_OPT: ${OpenCV_LIB_DIR_OPT}")
+  #message("OpenCV_LIB_DIR_DBG: ${OpenCV_LIB_DIR_DBG}")
+  #message("OpenCV_3RDPARTY_LIB_DIR_DBG: ${OpenCV_3RDPARTY_LIB_DIR_DBG}")
+  #message("OpenCV_3RDPARTY_LIB_DIR_OPT: ${OpenCV_3RDPARTY_LIB_DIR_OPT}")
+
+endif()

 find_package(OpenCV REQUIRED)
 list(APPEND ALL_LIBRARIES ${OpenCV_LIBS})
+
 # adding release directory for fixing error with RelWitgDebInfo (debug dlls have the suffix "d". thus release dlls wont be loaded accidentally)
 link_directories(${OpenCV_LIB_DIR} "${OpenCV_LIB_DIR}/Release")

+# adding option for videoinput library on windows (for directshow based frame grabbing)
 if(WIN32)
   option(MITK_USE_videoInput "Use videoInput (DirectShow wrapper) library" OFF)
 endif(WIN32)


Set SOFA lib search path in dependence on the OS

--- CMake/mitkFunctionGetLibrarySearchPaths.cmake
+++ CMake/mitkFunctionGetLibrarySearchPaths.cmake
@@ -57,6 +57,9 @@
     if(OpenCV_DIR)
       list(APPEND _dir_candidates "${OpenCV_DIR}/bin")
     endif()
+    if(SOFA_DIR)
+      list(APPEND _dir_candidates "${SOFA_DIR}/bin")
+    endif()
     list(APPEND _dir_candidates "${ITK_DIR}/bin")
   else()
     if(DCMTK_DIR)
@@ -64,6 +67,9 @@
     endif()
     if(OpenCV_DIR)
       list(APPEND _dir_candidates "${OpenCV_DIR}/lib")
+    endif()
+    if(SOFA_DIR)
+      list(APPEND _dir_candidates "${SOFA_DIR}/lib")
     endif()
     list(APPEND _dir_candidates "${ITK_DIR}/lib")
   endif()
@@ -103,9 +109,6 @@
   endif()
   if(Qxt_DIR)
     list(APPEND _dir_candidates "${Qxt_DIR}")
-  endif()
-  if(SOFA_DIR)
-    list(APPEND _dir_candidates "${SOFA_DIR}/bin")
   endif()
   if(MITK_USE_TOF_PMDO3 OR MITK_USE_TOF_PMDCAMCUBE OR MITK_USE_TOF_PMDCAMBOARD)
     list(APPEND _dir_candidates "${MITK_PMD_SDK_DIR}/plugins" "${MITK_PMD_SDK_DIR}/bin")


Check for errors with -Weverything

Check for errors with -Weverything

--- clang.cmake
+++ clang.cmake
@@ -1,7 +1,7 @@
 SET (CMAKE_C_COMPILER "clang")
 SET (CMAKE_CXX_COMPILER "clang++")

-SET(CMAKE_C_FLAGS "-pipe -Wall -Wextra -Wshadow -Wformat=2 -Wwrite-strings -std=c99 -pedantic" CACHE STRING "" FORCE)
+SET(CMAKE_C_FLAGS "-pipe -Weverything -std=c99 -pedantic" CACHE STRING "" FORCE)

 SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer" CACHE STRING "" FORCE)
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb" CACHE STRING "" FORCE)


[cmake] Fix libc++ detection

[cmake] Fix libc++ detection

-stdlib=libc++ is added to both the compilation and the link flags, but
the logic for adding it was only checking if it was supported during
compilation and not linking. This could lead to false positives, for
example when using clang with libstdc++ (where the compiler would
support -stdlib=libc++ but then linking would fail because of libc++
actually being unavailable).

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@330761 91177308-0d34-0410-b5e6-96231b3b80d8

--- cmake/modules/HandleLLVMStdlib.cmake
+++ cmake/modules/HandleLLVMStdlib.cmake
@@ -13,10 +13,12 @@
   endfunction()

   include(CheckCXXCompilerFlag)
+  include(CheckLinkerFlag)
   if(LLVM_ENABLE_LIBCXX)
     if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
-      check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
-      if(CXX_SUPPORTS_STDLIB)
+      check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
+      check_linker_flag("-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+      if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
         append("-stdlib=libc++"
           CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
           CMAKE_MODULE_LINKER_FLAGS)


Add RPATH with 'gnuinstall' option in addition to the 'rpath' option.

--- cmake/modules/RootBuildOptions.cmake
+++ cmake/modules/RootBuildOptions.cmake
@@ -143,6 +143,7 @@
 ROOT_BUILD_OPTION(gfal ON "GFAL support, requires libgfal")
 ROOT_BUILD_OPTION(glite ON "gLite support, requires libglite-api-wrapper v.3 from GSI (https://subversion.gsi.de/trac/dgrid/wiki)")
 ROOT_BUILD_OPTION(globus OFF "Globus authentication support, requires Globus toolkit")
+ROOT_BUILD_OPTION(gnuinstall OFF "Perform installation following the GNU guidelines")
 ROOT_BUILD_OPTION(gsl_shared OFF "Enable linking against shared libraries for GSL (default no)")
 ROOT_BUILD_OPTION(hdfs ON "HDFS support; requires libhdfs from HDFS >= 0.19.1")
 ROOT_BUILD_OPTION(http ${http_defvalue} "HTTP Server support")
@@ -178,7 +179,6 @@
 ROOT_BUILD_OPTION(sqlite ON "SQLite support, requires libsqlite3")
 ROOT_BUILD_OPTION(srp ON "SRP support, requires SRP source tree")
 ROOT_BUILD_OPTION(ssl ON "SSL encryption support, requires openssl")
-ROOT_BUILD_OPTION(gnuinstall OFF "Perform installation following the GNU guidelines")
 ROOT_BUILD_OPTION(tbb OFF "TBB multi-threading support, requires TBB")
 ROOT_BUILD_OPTION(table ${table_defvalue} "Build libTable contrib library")
 ROOT_BUILD_OPTION(tcmalloc OFF "Using the tcmalloc allocator")
@@ -225,7 +225,7 @@
 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # point to directories outside the build tree to the install RPATH

 # Check whether to add RPATH to the installation (the build tree always has the RPATH enabled)
-if(rpath)
+if(rpath OR gnuinstall)
   set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) # install LIBDIR
   set(CMAKE_SKIP_INSTALL_RPATH FALSE)          # don't skip the full RPATH for the install tree
 else()


Revert "Disable builtins by default, except llvm/clang"

This reverts commit fedad08aeb47d52e2428de9ecd365a2321ed6490.

--- cmake/modules/RootBuildOptions.cmake
+++ cmake/modules/RootBuildOptions.cmake
@@ -67,14 +67,14 @@
 ROOT_BUILD_OPTION(arrow OFF "Apache Arrow in memory columnar storage support")
 ROOT_BUILD_OPTION(astiff ON "Include tiff support in image processing")
 ROOT_BUILD_OPTION(bonjour OFF "Bonjour support, requires libdns_sd and/or Avahi")
-ROOT_BUILD_OPTION(builtin_afterimage OFF "Build included libAfterImage, or use system libAfterImage")
+ROOT_BUILD_OPTION(builtin_afterimage ON "Build included libAfterImage, or use system libAfterImage")
 ROOT_BUILD_OPTION(builtin_cfitsio OFF "Build the FITSIO library internally (downloading tarfile from the Web)")
 ROOT_BUILD_OPTION(builtin_davix OFF "Build the Davix library internally (downloading tarfile from the Web)")
 ROOT_BUILD_OPTION(builtin_fftw3 OFF "Build the FFTW3 library internally (downloading tarfile from the Web)")
 ROOT_BUILD_OPTION(builtin_freetype OFF "Build included libfreetype, or use system libfreetype")
-ROOT_BUILD_OPTION(builtin_ftgl OFF "Build included libFTGL, or use system libftgl")
+ROOT_BUILD_OPTION(builtin_ftgl ON "Build included libFTGL, or use system libftgl")
 ROOT_BUILD_OPTION(builtin_gl2ps OFF "Build included libgl2ps, or use system libgl2ps")
-ROOT_BUILD_OPTION(builtin_glew OFF "Build included libGLEW, or use system libGLEW")
+ROOT_BUILD_OPTION(builtin_glew ON "Build included libGLEW, or use system libGLEW")
 ROOT_BUILD_OPTION(builtin_gsl OFF "Build the GSL library internally (downloading tarfile from the Web)")
 ROOT_BUILD_OPTION(builtin_llvm ON "Build llvm internally")
 ROOT_BUILD_OPTION(builtin_clang ON "Build clang internally")


fix finding qt libraries on windows

fix finding qt libraries on windows

LOCATION points to the dll, what we need is the .lib

Change-Id: Iddc594cedb08d6e12b3066fab5f0f66440518086

--- cmake/qibuild/modules/qt5utils.cmake
+++ cmake/qibuild/modules/qt5utils.cmake
@@ -12,11 +12,12 @@
   find_package(${name})
   foreach(_lib ${${name}_LIBRARIES})
     if(WIN32)
-      get_target_property(_lib_loc_debug ${_lib} LOCATION_DEBUG)
-      get_target_property(_lib_loc_release ${_lib} LOCATION_RELEASE)
+      get_target_property(_imported_lib_debug ${_lib} IMPORTED_IMPLIB_DEBUG)
+      get_target_property(_imported_lib_release ${_lib} IMPORTED_IMPLIB_RELEASE)
       list(APPEND ${prefix}_LIBRARIES
-      debug "${_lib_loc_debug}"
-      optimized "${_lib_loc_release}")
+        optimized ${_imported_lib_release}
+        debug ${_imported_lib_debug}
+      )
     else()
       get_target_property(_lib_loc ${_lib} LOCATION)
       list(APPEND ${prefix}_LIBRARIES ${_lib_loc})


Updated FindTBB.cmake to correctly identify the version of Visual Studio used

--- CMake/Packages/FindTBB.cmake
+++ CMake/Packages/FindTBB.cmake
@@ -49,13 +49,16 @@
 # to detect the "best" version to use. The user will have to manually
 # select the right files. (Chances are the distributions are shipping their
 # custom version of tbb, anyway, so the problem is probably nonexistant.)
-if (WIN32)
+if (WIN32 AND MSVC)
   set(COMPILER_PREFIX "vc7.1")
-  if (MSVC80)
+  if (MSVC_VERSION EQUAL 1400)
     set(COMPILER_PREFIX "vc8")
   endif ()
-  if (MSVC90)
+  if (MSVC_VERSION EQUAL 1500)
     set(COMPILER_PREFIX "vc9")
+  endif ()
+  if (MSVC_VERSION EQUAL 1600)
+    set(COMPILER_PREFIX "vc10")
   endif ()

   # for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path


py/py.cmake: Add missing Pycopy sources.

Change-Id: I63dd8ac480ed0bb71bbff87c01695f77762a81e2
Signed-off-by: Paul Sokolovsky <9dc5061f178bb11813e14f1ed02ba27eaf21fa5d@users.sourceforge.net>

--- py/py.cmake
+++ py/py.cmake
@@ -93,6 +93,7 @@
     ${MICROPY_PY_DIR}/objstr.c
     ${MICROPY_PY_DIR}/objstringio.c
     ${MICROPY_PY_DIR}/objstrunicode.c
+    ${MICROPY_PY_DIR}/objtextio.c
     ${MICROPY_PY_DIR}/objtuple.c
     ${MICROPY_PY_DIR}/objtype.c
     ${MICROPY_PY_DIR}/objzip.c
@@ -117,6 +118,7 @@
     ${MICROPY_PY_DIR}/smallint.c
     ${MICROPY_PY_DIR}/stackctrl.c
     ${MICROPY_PY_DIR}/stream.c
+    ${MICROPY_PY_DIR}/strict_mode.c
     ${MICROPY_PY_DIR}/unicode.c
     ${MICROPY_PY_DIR}/vm.c
     ${MICROPY_PY_DIR}/vstr.c


Use only variables which are available for external projects.

--- CMake/mitkInstallRules.cmake
+++ CMake/mitkInstallRules.cmake
@@ -33,13 +33,15 @@
   endif()

   #BlueBerry
+  # Since this file is also included from external projects, you
+  # can only use variables which are made available through MITKConfig.cmake
   if(MITK_USE_BLUEBERRY)
     if(MINGW)
-      MITK_INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins/liborg_blueberry_osgi.dll)
+      MITK_INSTALL(FILES ${MITK_BINARY_DIR}/bin/plugins/liborg_blueberry_osgi.dll)
     else()
       if(NOT APPLE)
-        MITK_INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins/debug/liborg_blueberry_osgi.dll CONFIGURATIONS Debug)
-        MITK_INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins/release/liborg_blueberry_osgi.dll CONFIGURATIONS Release)
+        MITK_INSTALL(FILES ${MITK_BINARY_DIR}/bin/plugins/debug/liborg_blueberry_osgi.dll CONFIGURATIONS Debug)
+        MITK_INSTALL(FILES ${MITK_BINARY_DIR}/bin/plugins/release/liborg_blueberry_osgi.dll CONFIGURATIONS Release)
       endif(NOT APPLE)
     endif()
   endif()


remove unnecessary conditional

remove unnecessary conditional

--- standard/StandardProject.cmake
+++ standard/StandardProject.cmake
@@ -87,10 +87,8 @@
     endforeach()
   endif()

-  # We want Position independent code for all 64-bit non-windows builds
-  if(NOT WIN32)
-    set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE INTERNAL "Position-Independent Code")
-  endif()
+  # We want Position independent code for all builds
+  set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE INTERNAL "Position-Independent Code")
 endfunction()

 function(standard_project_postinit)


COMP: Avoid MetaIO config conflict with USE_SYSTEM_GDCM.

When a system GDCM with configured with VTK support, its UseGDCM.cmake file
can call include(${VTK_USE_FILE}).  This can cause VTK's include directories
to fall before ITK's, the system can find VTK's metaIOConfig.h first, and
MetaIO build failures will occurue.

Change-Id: Ided8ec692a10fdde423f9f4fec521727d7b4b83e

--- Modules/ThirdParty/GDCM/itk-module-init.cmake
+++ Modules/ThirdParty/GDCM/itk-module-init.cmake
@@ -3,5 +3,8 @@

 if(ITK_USE_SYSTEM_GDCM)
   find_package(GDCM REQUIRED)
+  # Avoid UseGDCM.cmake calling include(${VTK_USE_FILE}), which include's
+  # VTK's include paths before ITK and causes a MetaIO conflict.
+  set(GDCM_USE_VTK FALSE)
   include(${GDCM_USE_FILE})
 endif()


Fix PKG_CONFIG_LIBDIR

Fix PKG_CONFIG_LIBDIR

[skip ci]

--- cmake/modules/hunter_autotools_project.cmake
+++ cmake/modules/hunter_autotools_project.cmake
@@ -61,6 +61,8 @@
 include(hunter_status_debug)
 include(hunter_test_string_not_empty)

+# Packages to test this function:
+# * xau
 function(hunter_autotools_project target_name)
   set(optional_params)
   set(one_value_params
@@ -109,8 +111,8 @@
   set(default_path "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin")
   set(shell_env_path "PATH=${PARAM_GLOBAL_INSTALL_DIR}/bin:${default_path}")

-  set(d1 "${root_id}/lib/pkgconfig")
-  set(d2 "${root_id}/share/pkgconfig")
+  set(d1 "${PARAM_GLOBAL_INSTALL_DIR}/lib/pkgconfig")
+  set(d2 "${PARAM_GLOBAL_INSTALL_DIR}/share/pkgconfig")
   set(shell_pkg_config_libdir "PKG_CONFIG_LIBDIR=${d1}:${d2}")

   set(clear_vars_shell_script "${PARAM_HUNTER_SELF}/scripts/clear-all.sh")


Autotools - use build config's linking/compiling flags/definition

--- cmake/modules/hunter_autotools_project.cmake
+++ cmake/modules/hunter_autotools_project.cmake
@@ -26,6 +26,8 @@
 #       "@HUNTER_INSTALL_PREFIX@"
 #     PARALLEL_JOBS                           # number of parallel jobs for make
 #       "@HUNTER_JOBS_OPTION@"
+#     PACKAGE_CONFIGURATION_TYPES             # build configuration (Release|Debug)
+#       "@HUNTER_PACKAGE_CONFIGURATION_TYPES@"
 #     CPPFLAGS                                # C pre-processor flags
 #       "-DEXAMPLE -I/usr/local/include/library"
 #     CFLAGS                                  # C Compiler flags
@@ -74,7 +76,10 @@
       LDFLAGS
       BOOTSTRAP
   )
-  set(multi_value_params EXTRA_FLAGS)
+  set(multi_value_params
+      PACKAGE_CONFIGURATION_TYPES
+      EXTRA_FLAGS
+  )
   cmake_parse_arguments(
       PARAM
       "${optional_params}"
@@ -98,7 +103,17 @@
   hunter_test_string_not_empty("${PARAM_BUILD_DIR}")
   hunter_test_string_not_empty("${PARAM_GLOBAL_INSTALL_DIR}")
   hunter_test_string_not_empty("${PARAM_INSTALL_DIR}")
-
+  hunter_test_string_not_empty("${PARAM_PACKAGE_CONFIGURATION_TYPES}")
+
+  list(LENGTH PARAM_PACKAGE_CONFIGURATION_TYPES len)
+  if(NOT "${len}" EQUAL "1")
+    hunter_fatal_error(
+        "Autotools PACKAGE_CONFIGURATION_TYPES has ${len} elements: ${PARAM_PACKAGE_CONFIGURATION_TYPES}. Only 1 is allowed"
+        WIKI "autools.package.configuration.types"
+    )
+  endif()
+
+  string(TOUPPER ${PARAM_PACKAGE_CONFIGURATION_TYPES} config_type)
   # Sets the toolchain binaries
   #   AR=${CMAKE_AR}
   #   AS=${CMAKE_ASM_COMPILER}
@@ -163,6 +178,14 @@
   #
   # C Preprocessor flags
   set(cppflags)
+  # build config type definitions
+  get_directory_property(defs
+      COMPILE_DEFINITIONS_${config_type}
+  )
+  foreach(def ${defs})
+    set(cppflags "${cppflags} -D${def}")
+  endforeach()
+  # non-build config specific definitions
   get_directory_property(defs COMPILE_DEFINITIONS)
   foreach(def ${defs})
     set(cppflags "${cppflags} -D${def}")
@@ -182,21 +205,21 @@
   # CFLAGS=${cflags} ${CMAKE_C_FLAGS}
   #
   # C Compiler Flags (defines or include directories should not be needed here)
-  set(cflags "${CMAKE_C_FLAGS} ${PARAM_CFLAGS}")
+  set(cflags "${CMAKE_C_FLAGS_${config_type}} ${CMAKE_C_FLAGS} ${PARAM_CFLAGS}")
   string(STRIP "${cflags}" cflags)
   hunter_status_debug("CFLAGS=${cflags}")

   # CXXFLAGS=${cxxflags} ${CMAKE_CXX_FLAGS}
   #
   # C++ Compiler flags (defines or include directories should not be needed here)
-  set(cxxflags "${CMAKE_CXX_FLAGS} ${PARAM_CXXFLAGS}")
+  set(cxxflags "${CMAKE_CXX_FLAGS_${config_type}} ${CMAKE_CXX_FLAGS} ${PARAM_CXXFLAGS}")
   string(STRIP "${cxxflags}" cxxflags)
   hunter_status_debug("CXXFLAGS=${cxxflags}")

   # LDFLAGS=${ldflags}
   #
   # Linker flags
-  set(ldflags "${CMAKE_EXE_LINKER_FLAGS} ${PARAM_LDFLAGS}")
+  set(ldflags "${CMAKE_EXE_LINKER_FLAGS_${config_type}} ${CMAKE_EXE_LINKER_FLAGS} ${PARAM_LDFLAGS}")
   string(STRIP "${ldflags}" ldflags)
   hunter_status_debug("LDFLAGS=${ldflags}")