$OpenBSD: patch-src_CMakeLists_txt,v 1.3 2013/06/24 10:35:14 dcoppa Exp $

Unbreak SEPARATE_BUILD
Unbreak with Ninja

--- src/CMakeLists.txt.orig	Wed May 16 21:48:34 2012
+++ src/CMakeLists.txt	Mon Jun 24 12:07:34 2013
@@ -1,5 +1,5 @@
 SET(CMAKE_INCLUDE_CURRENT_DIR ON)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../include ${NEON_INCLUDE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../include ${CMAKE_CURRENT_BINARY_DIR}/../include ${NEON_INCLUDE_DIR})
 
 SET(_sources Alias.cc Annotation.cc Artist.cc ArtistCredit.cc Attribute.cc CDStub.cc Collection.cc
 	Disc.cc Entity.cc FreeDBDisc.cc HTTPFetch.cc ISRC.cc Label.cc LabelInfo.cc Lifespan.cc List.cc
@@ -8,18 +8,33 @@ SET(_sources Alias.cc Annotation.cc Artist.cc ArtistCr
 	TextRepresentation.cc Track.cc UserRating.cc UserTag.cc Work.cc xmlParser.cpp
 	RelationListList.cc ISWCList.cc ISWC.cc SecondaryType.cc SecondaryTypeList.cc IPI.cc)
 
+FILE(GLOB inc_src_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*.inc")
+
+foreach(inc_file ${inc_src_files})
+	ADD_CUSTOM_COMMAND(
+		OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${inc_file}
+		COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${inc_file} ${CMAKE_CURRENT_BINARY_DIR}/${inc_file}
+		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}
+	)
+	list(APPEND inc_binary_files ${CMAKE_CURRENT_BINARY_DIR}/${inc_file})
+endforeach()
+
+ADD_CUSTOM_TARGET(Copy_inc_Files DEPENDS ${inc_binary_files})
+
 ADD_EXECUTABLE(make-c-interface make-c-interface.cc xmlParser.cpp)
 
 ADD_CUSTOM_COMMAND(
 	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mb5_c.cc ${CMAKE_CURRENT_BINARY_DIR}/mb5_c.h ${CMAKE_CURRENT_BINARY_DIR}/../include/musicbrainz5/mb5_c.h
+	COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/musicbrainz5
 	COMMAND make-c-interface ${CMAKE_CURRENT_SOURCE_DIR} cinterface.xml ${CMAKE_CURRENT_BINARY_DIR} mb5_c.cc mb5_c.h
 	COMMAND ${CMAKE_COMMAND} -E copy_if_different 	${CMAKE_CURRENT_BINARY_DIR}/mb5_c.h ${CMAKE_CURRENT_BINARY_DIR}/../include/musicbrainz5
-	DEPENDS make-c-interface cinterface.xml *.inc
+	DEPENDS Copy_inc_Files make-c-interface cinterface.xml
 )
 
 ADD_CUSTOM_TARGET(src_gen DEPENDS mb5_c.h)
 
 ADD_LIBRARY(musicbrainz5 SHARED ${_sources})
+ADD_DEPENDENCIES(musicbrainz5 src_gen)
 
 SET_TARGET_PROPERTIES(musicbrainz5 PROPERTIES
     VERSION ${musicbrainz5_VERSION}
