From 9f423fc99a0191f16e96a74ded8bd57556080e8c Mon Sep 17 00:00:00 2001
From: Cameron Lowell Palmer <cameron@promon.no>
Date: Thu, 24 May 2018 12:06:24 +0200
Subject: [PATCH] Use target_include_directories instead of include_directories
 in CMakeLists.txt

---
 apps/nc/CMakeLists.txt        | 11 ++++-------
 apps/ocspcheck/CMakeLists.txt | 11 ++++-------
 apps/openssl/CMakeLists.txt   |  9 +++------
 crypto/CMakeLists.txt         | 23 ++++++++++++-----------
 ssl/CMakeLists.txt            | 13 +++++++------
 tests/CMakeLists.txt          |  2 --
 tls/CMakeLists.txt            | 13 +++++++------
 7 files changed, 37 insertions(+), 45 deletions(-)

diff --git a/apps/nc/CMakeLists.txt b/apps/nc/CMakeLists.txt
index 64d14fa..5b18c88 100644
--- a/apps/nc/CMakeLists.txt
+++ b/apps/nc/CMakeLists.txt
@@ -1,12 +1,5 @@
 if(BUILD_NC)
 
-include_directories(
-	.
-	./compat
-	../../include
-	../../include/compat
-)
-
 set(
 	NC_SRC
 	atomicio.c
@@ -50,6 +43,10 @@ else()
 endif()
 
 add_executable(nc ${NC_SRC})
+target_include_directories(nc
+		PRIVATE
+			.
+			./compat)
 target_link_libraries(nc tls ${OPENSSL_LIBS})
 
 if(ENABLE_NC)
diff --git a/apps/ocspcheck/CMakeLists.txt b/apps/ocspcheck/CMakeLists.txt
index 15af8a8..77e5e78 100644
--- a/apps/ocspcheck/CMakeLists.txt
+++ b/apps/ocspcheck/CMakeLists.txt
@@ -1,12 +1,5 @@
 if(NOT MSVC)
 
-include_directories(
-	.
-	./compat
-	../../include
-	../../include/compat
-)
-
 set(
 	OCSPCHECK_SRC
 	http.c
@@ -27,6 +20,10 @@ else()
 endif()
 
 add_executable(ocspcheck ${OCSPCHECK_SRC})
+target_include_directories(ocspcheck
+		PRIVATE
+			.
+			./compat)
 target_link_libraries(ocspcheck tls ${OPENSSL_LIBS})
 
 if(ENABLE_LIBRESSL_INSTALL)
diff --git a/apps/openssl/CMakeLists.txt b/apps/openssl/CMakeLists.txt
index 8b800c4..53617cc 100644
--- a/apps/openssl/CMakeLists.txt
+++ b/apps/openssl/CMakeLists.txt
@@ -1,9 +1,3 @@
-include_directories(
-	.
-	../../include
-	../../include/compat
-)
-
 set(
 	OPENSSL_SRC
 	apps.c
@@ -74,6 +68,9 @@ else()
 endif()
 
 add_executable(openssl ${OPENSSL_SRC})
+taget_include_directories(openssl
+		PRIVATE
+			.)
 target_link_libraries(openssl ${OPENSSL_LIBS})
 
 if(ENABLE_LIBRESSL_INSTALL)
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index 2fa08a5..0c4f4ba 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -1,14 +1,3 @@
-include_directories(
-	.
-	../include
-	../include/compat
-	asn1
-	bn
-	dsa
-	evp
-	modes
-)
-
 if(HOST_ASM_ELF_X86_64)
 	set(
 		ASM_X86_64_ELF_SRC
@@ -810,6 +799,18 @@ if(EXTRA_EXPORT)
 endif()
 
 add_library(crypto ${CRYPTO_SRC})
+target_include_directories(crypto
+		PRIVATE
+			.
+			asn1
+			bn
+			dsa
+			evp
+			modes
+		PUBLIC
+			../include
+			../include/compat)
+
 if (BUILD_SHARED_LIBS)
 	export_symbol(crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto_p.sym)
 	if (WIN32)
diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt
index e87e0f6..7abb012 100644
--- a/ssl/CMakeLists.txt
+++ b/ssl/CMakeLists.txt
@@ -1,9 +1,3 @@
-include_directories(
-	.
-	../include
-	../include/compat
-)
-
 set(
 	SSL_SRC
 	bio_ssl.c
@@ -48,6 +42,13 @@ set(
 )
 
 add_library(ssl ${SSL_SRC})
+target_include_directories(ssl
+		PRIVATE
+			.
+		PUBLIC
+			../include
+			../include/compat)
+
 if (BUILD_SHARED_LIBS)
 	export_symbol(ssl ${CMAKE_CURRENT_SOURCE_DIR}/ssl.sym)
 	target_link_libraries(ssl crypto)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 9c79313..065d934 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,5 @@
 include_directories(
 	.
-	../include
-	../include/compat
 	../crypto/modes
 	../crypto/asn1
 	../ssl
diff --git a/tls/CMakeLists.txt b/tls/CMakeLists.txt
index 6c5303c..0c8d731 100644
--- a/tls/CMakeLists.txt
+++ b/tls/CMakeLists.txt
@@ -1,9 +1,3 @@
-include_directories(
-	.
-	../include
-	../include/compat
-)
-
 set(
 	TLS_SRC
 	tls.c
@@ -37,6 +31,13 @@ else()
 endif()
 
 add_library(tls ${TLS_SRC})
+target_include_directories(tls
+		PRIVATE
+			.
+		PUBLIC
+			../include
+			../include/compat)
+
 if (BUILD_SHARED_LIBS)
 	export_symbol(tls ${CMAKE_CURRENT_SOURCE_DIR}/tls.sym)
 	target_link_libraries(tls ssl crypto)
-- 
2.16.2

