cmake: move pthread detection earlier

I'm working on making the sysrepo/netconf backends optional, and I'm
making my life more miserable by supporting the usual autoconf-like
auto/on/off tristate values. That means that I'll be changing this code
with some STATUS messages, and I want to prevent a scenario where I
print out "enabling tests" before failing later with an unrelated error
about pthread.

Change-Id: Ie276a194b264eb0add6ac0c5eb850eeaa462080a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b73aa56..7a04d1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,12 @@
 include(cmake/ProjectGitVersion.cmake)
 prepare_git_version(NETCONF_CLI_VERSION "0.0")
 
+# Boost.Process needs linking with threads, but doesn't have special CMake target which would do that for us. So, we
+# need to link manually. This will hopefully change in the future.
+# https://discourse.cmake.org/t/boost-process-target-doesnt-exist-for-thread-linking/2113
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads)
+
 find_package(Doxygen)
 option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND})
 
@@ -172,11 +178,6 @@
     )
 target_compile_definitions(netconf-cli PRIVATE NETCONF_CLI)
 
-# Boost.Process needs linking with threads, but doesn't have special CMake target which would do that for us. So, we
-# need to link manually. This will hopefully change in the future.
-# https://discourse.cmake.org/t/boost-process-target-doesnt-exist-for-thread-linking/2113
-set(THREADS_PREFER_PTHREAD_FLAG ON)
-find_package(Threads)
 target_link_libraries(netconf-cli netconfaccess Threads::Threads Boost::filesystem)
 cli_link_required(netconf-cli)