$OpenBSD: patch-build_CMakeLists_txt,v 1.4 2014/12/25 19:41:07 dcoppa Exp $
--- build/CMakeLists.txt.orig	Sat Nov  2 11:22:55 2013
+++ build/CMakeLists.txt	Wed Dec 24 15:38:18 2014
@@ -29,48 +29,48 @@ if(DEBUG)
 		"-Wstack-protector -fstack-protector"
 		"-Wstrict-aliasing -fstrict-aliasing")
 	join("${_arg_str}" CMAKE_C_FLAGS)
-else(DEBUG)
-	set(_arg_str "${CMAKE_C_FLAGS} -ansi -O2"
-		"-Wuninitialized"
-		"-Wstack-protector -fstack-protector")
-	if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
-		set(_arg_str "${_arg_str}"
-			"-Wno-dangling-else"
-			# avoid the "argument unused" error in clang
-			"-Qunused-arguments")
-	endif()
-	join("${_arg_str}" CMAKE_C_FLAGS)
+#else(DEBUG)
+#	set(_arg_str "${CMAKE_C_FLAGS} -ansi -O2"
+#		"-Wuninitialized"
+#		"-Wstack-protector -fstack-protector")
+#	if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+#		set(_arg_str "${_arg_str}"
+#			"-Wno-dangling-else"
+#			# avoid the "argument unused" error in clang
+#			"-Qunused-arguments")
+#	endif()
+#	join("${_arg_str}" CMAKE_C_FLAGS)
 endif(DEBUG)
 
 # generate the public headers
 add_custom_target(headers ALL DEPENDS
-	../cl/extern.h ../common/extern.h ../ex/extern.h ../vi/extern.h
-	../common/options_def.h ../ex/ex_def.h ../ex/version.h)
+	cl_extern.h common_extern.h ex_extern.h vi_extern.h
+	options_def.h ex_def.h version.h)
 
 set(extract_protos sed -n 's/^ \\* PUBLIC: \\\(.*\\\)/\\1/p')
 set(extract_version sed -n
 	's/^.*version \\\([^\)]*\)\\\).*/\#define VI_VERSION \\\"\\1\\\"/p')
-add_custom_command(OUTPUT ../cl/extern.h
-	COMMAND ${extract_protos} ../cl/*.c > $@
-	DEPENDS ../cl/*.c)
-add_custom_command(OUTPUT ../common/extern.h
-	COMMAND ${extract_protos} ../common/*.c > $@
-	DEPENDS ../common/*.c)
-add_custom_command(OUTPUT ../ex/extern.h
-	COMMAND ${extract_protos} ../ex/*.c > $@
-	DEPENDS ../ex/*.c)
-add_custom_command(OUTPUT ../vi/extern.h
-	COMMAND ${extract_protos} ../vi/*.c > $@
-	DEPENDS ../vi/*.c)
-add_custom_command(OUTPUT ../common/options_def.h
-	COMMAND awk -f ../common/options.awk ../common/options.c > $@
-	DEPENDS ../common/options.c)
-add_custom_command(OUTPUT ../ex/ex_def.h
-	COMMAND awk -f ../ex/ex.awk ../ex/ex_cmd.c > $@
-	DEPENDS ../ex/ex_cmd.c)
-add_custom_command(OUTPUT ../ex/version.h
-	COMMAND ${extract_version} ../README > $@
-	DEPENDS ../README)
+add_custom_command(OUTPUT cl_extern.h
+	COMMAND ${extract_protos} *.c > cl_extern.h
+	WORKING_DIRECTORY ../cl/)
+add_custom_command(OUTPUT common_extern.h
+	COMMAND ${extract_protos} *.c > common_extern.h
+	WORKING_DIRECTORY ../common/)
+add_custom_command(OUTPUT ex_extern.h
+	COMMAND ${extract_protos} *.c > ex_extern.h
+	WORKING_DIRECTORY ../ex/)
+add_custom_command(OUTPUT vi_extern.h
+	COMMAND ${extract_protos} *.c > vi_extern.h
+	WORKING_DIRECTORY ../vi/)
+add_custom_command(OUTPUT options_def.h
+	COMMAND awk -f options.awk options.c > options_def.h
+	WORKING_DIRECTORY ../common/)
+add_custom_command(OUTPUT ex_def.h
+	COMMAND awk -f ex.awk ex_cmd.c > ex_def.h
+	WORKING_DIRECTORY ../ex/)
+add_custom_command(OUTPUT version.h
+	COMMAND ${extract_version} ../README > version.h
+	WORKING_DIRECTORY ../ex/)
 
 FILE(GLOB MAIN_SRCS ../cl/*.c ../common/*.c ../ex/*.c ../vi/*.c)
 FILE(GLOB REGEX_SRCS ../regex/reg*.c)
@@ -154,6 +154,7 @@ configure_file(${CMAKE_SOURCE_DIR}/recover.in
 	${CMAKE_SOURCE_DIR}/recover @ONLY)
 
 add_executable(nvi ${MAIN_SRCS})
+add_dependencies(nvi headers)
 target_link_libraries(nvi ${CURSES_LIBRARY} ${UTIL_LIBRARY} ${RESOLV_LIBRARY})
 if(USE_WIDECHAR)
 	target_link_libraries(nvi regex)
