From 28b12c85f44c6008c3eac5b40ea2f911a4bd7661 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 11 Apr 2019 11:03:30 +1000 Subject: [PATCH] [build] make "common" a static library (part 1/2) --- VERSION | 2 +- c-host/CMakeLists.txt | 6 ++++-- c-host/platform/Windows/CMakeLists.txt | 1 + .../platform/Windows/capture/CMakeLists.txt | 13 ++++++------ .../Windows/capture/DXGI/CMakeLists.txt | 1 + .../platform/Windows/capture/DXGI/src/dxgi.c | 4 ++-- .../include/windows/{windebug.h => debug.h} | 2 +- c-host/platform/Windows/src/mousehook.c | 2 +- c-host/platform/Windows/src/platform.c | 4 ++-- c-host/platform/Windows/src/windebug.c | 2 +- c-host/src/app.c | 6 +++--- common/CMakeLists.txt | 20 +++++++++++++++++++ common/{ => include/common}/KVMFR.h | 0 common/{ => include/common}/debug.h | 0 common/{ => include/common}/locking.h | 0 common/{ => include/common}/memcpySSE.h | 0 common/src/debug.c | 0 common/{ => src}/memcpySSE.asm | 0 host/IVSHMEM.cpp | 2 +- host/looking-glass-host.vcxproj | 18 ++++++++--------- host/looking-glass-host.vcxproj.filters | 10 +++++----- host/main.cpp | 2 +- 22 files changed, 60 insertions(+), 35 deletions(-) rename c-host/platform/Windows/include/windows/{windebug.h => debug.h} (97%) create mode 100644 common/CMakeLists.txt rename common/{ => include/common}/KVMFR.h (100%) rename common/{ => include/common}/debug.h (100%) rename common/{ => include/common}/locking.h (100%) rename common/{ => include/common}/memcpySSE.h (100%) create mode 100644 common/src/debug.c rename common/{ => src}/memcpySSE.asm (100%) diff --git a/VERSION b/VERSION index 5bad1341..96754613 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -a12-149-g878eb057d1+1 \ No newline at end of file +a12-150-gbee221c18d+1 \ No newline at end of file diff --git a/c-host/CMakeLists.txt b/c-host/CMakeLists.txt index 8acce248..007e6ab3 100644 --- a/c-host/CMakeLists.txt +++ b/c-host/CMakeLists.txt @@ -33,12 +33,12 @@ execute_process( ) add_definitions(-D BUILD_VERSION='"${BUILD_VERSION}"') +get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE) include_directories( ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include - ${PROJECT_SOURCE_DIR}/../common - ${PROJECT_SOURCE_DIR}/../vendor/kvm-guest-drivers-windows + ${PROJECT_TOP}/vendor/kvm-guest-drivers-windows ${PKGCONFIG_INCLUDE_DIRS} ${GMP_INCLUDE_DIR} ) @@ -50,6 +50,7 @@ set(SOURCES src/app.c ) +add_subdirectory("${PROJECT_TOP}/common" "${CMAKE_BINARY_DIR}/common") add_subdirectory(platform) if(WIN32) @@ -58,6 +59,7 @@ else() add_executable(looking-glass-host ${SOURCES}) endif() target_link_libraries(looking-glass-host + lg_common platform ) set_target_properties(looking-glass-host PROPERTIES LINK_FLAGS "-Wl,--gc-sections") diff --git a/c-host/platform/Windows/CMakeLists.txt b/c-host/platform/Windows/CMakeLists.txt index aca29196..0629d675 100644 --- a/c-host/platform/Windows/CMakeLists.txt +++ b/c-host/platform/Windows/CMakeLists.txt @@ -22,6 +22,7 @@ ADD_CUSTOM_COMMAND(TARGET platform_Windows POST_BUILD target_link_libraries(platform_Windows "${PROJECT_BINARY_DIR}/resource.o" + lg_common capture setupapi ) diff --git a/c-host/platform/Windows/capture/CMakeLists.txt b/c-host/platform/Windows/capture/CMakeLists.txt index 18a721d4..409e766e 100644 --- a/c-host/platform/Windows/capture/CMakeLists.txt +++ b/c-host/platform/Windows/capture/CMakeLists.txt @@ -1,19 +1,20 @@ cmake_minimum_required(VERSION 3.0) project(capture LANGUAGES C) -include("PreCapture") +include(PreCapture) + +option(USE_NVFBC "Enable NVFBC Support" OFF) +option(USE_DXGI "Enable DXGI Support" ON) if(NOT DEFINED NVFBC_SDK) set(NVFBC_SDK "C:\\Program Files (x86)\\NVIDIA Corporation\\NVIDIA Capture SDK") endif() -if(EXISTS "${NVFBC_SDK}\\inc" AND IS_DIRECTORY "${NVFBC_SDK}\\inc") - set(USE_NVFBC ON) +if(NOT EXISTS "${NVFBC_SDK}\\inc" OR NOT IS_DIRECTORY "${NVFBC_SDK}\\inc") + message("Disabling NVFBC support, can't find the SDK headers") + set(USE_NVFBC OFF) endif() -option(USE_NVFBC "Enable NVFBC Support" ${USE_NVFBC}) -option(USE_DXGI "Enable DXGI Support" ON) - if(USE_NVFBC) add_capture("NVFBC") endif() diff --git a/c-host/platform/Windows/capture/DXGI/CMakeLists.txt b/c-host/platform/Windows/capture/DXGI/CMakeLists.txt index 4017e035..8fc82c4d 100644 --- a/c-host/platform/Windows/capture/DXGI/CMakeLists.txt +++ b/c-host/platform/Windows/capture/DXGI/CMakeLists.txt @@ -15,6 +15,7 @@ ADD_CUSTOM_COMMAND(TARGET capture_DXGI POST_BUILD ) target_link_libraries(capture_DXGI + lg_common ${PROJECT_BINARY_DIR}/libd3d11.dll dxgi ) diff --git a/c-host/platform/Windows/capture/DXGI/src/dxgi.c b/c-host/platform/Windows/capture/DXGI/src/dxgi.c index 32be656f..6a5f6122 100644 --- a/c-host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/c-host/platform/Windows/capture/DXGI/src/dxgi.c @@ -19,8 +19,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "interface/capture.h" #include "interface/platform.h" -#include "debug.h" -#include "windows/windebug.h" +#include "common/debug.h" +#include "windows/debug.h" #include #include diff --git a/c-host/platform/Windows/include/windows/windebug.h b/c-host/platform/Windows/include/windows/debug.h similarity index 97% rename from c-host/platform/Windows/include/windows/windebug.h rename to c-host/platform/Windows/include/windows/debug.h index 50cb06b0..7bfd68b6 100644 --- a/c-host/platform/Windows/include/windows/windebug.h +++ b/c-host/platform/Windows/include/windows/debug.h @@ -19,7 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #pragma once -#include "debug.h" +#include "common/debug.h" #include #ifdef __cplusplus diff --git a/c-host/platform/Windows/src/mousehook.c b/c-host/platform/Windows/src/mousehook.c index a3da302a..40a3d8da 100644 --- a/c-host/platform/Windows/src/mousehook.c +++ b/c-host/platform/Windows/src/mousehook.c @@ -18,7 +18,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA */ #include "windows/mousehook.h" -#include "windows/windebug.h" +#include "windows/debug.h" #include "platform.h" #include diff --git a/c-host/platform/Windows/src/platform.c b/c-host/platform/Windows/src/platform.c index ab6a8425..e00c25f2 100644 --- a/c-host/platform/Windows/src/platform.c +++ b/c-host/platform/Windows/src/platform.c @@ -24,8 +24,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include "interface/platform.h" -#include "debug.h" -#include "windows/windebug.h" +#include "common/debug.h" +#include "windows/debug.h" #include "ivshmem/Public.h" static HANDLE shmemHandle = INVALID_HANDLE_VALUE; diff --git a/c-host/platform/Windows/src/windebug.c b/c-host/platform/Windows/src/windebug.c index 9d7fef2c..33d20b11 100644 --- a/c-host/platform/Windows/src/windebug.c +++ b/c-host/platform/Windows/src/windebug.c @@ -17,7 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "windows/windebug.h" +#include "windows/debug.h" #include void DebugWinError(const char * file, const unsigned int line, const char * function, const char * desc, HRESULT status) diff --git a/c-host/src/app.c b/c-host/src/app.c index 2337284e..990693ad 100644 --- a/c-host/src/app.c +++ b/c-host/src/app.c @@ -20,15 +20,15 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "interface/platform.h" #include "interface/capture.h" #include "dynamic/capture.h" +#include "common/debug.h" +#include "common/locking.h" +#include "common/KVMFR.h" #include #include #include #include #include -#include "debug.h" -#include "locking.h" -#include "KVMFR.h" #define ALIGN_DN(x) ((uintptr_t)(x) & ~0x7F) #define ALIGN_UP(x) ALIGN_DN(x + 0x7F) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt new file mode 100644 index 00000000..45f31490 --- /dev/null +++ b/common/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.0) +project(lg_common LANGUAGES C) + +include_directories( + ${PROJECT_SOURCE_DIR}/include +) + +add_library(lg_common STATIC + src/debug.c +) + +#target_link_libraries(lg_common +#) + +target_include_directories(lg_common + INTERFACE + include + PRIVATE + src +) diff --git a/common/KVMFR.h b/common/include/common/KVMFR.h similarity index 100% rename from common/KVMFR.h rename to common/include/common/KVMFR.h diff --git a/common/debug.h b/common/include/common/debug.h similarity index 100% rename from common/debug.h rename to common/include/common/debug.h diff --git a/common/locking.h b/common/include/common/locking.h similarity index 100% rename from common/locking.h rename to common/include/common/locking.h diff --git a/common/memcpySSE.h b/common/include/common/memcpySSE.h similarity index 100% rename from common/memcpySSE.h rename to common/include/common/memcpySSE.h diff --git a/common/src/debug.c b/common/src/debug.c new file mode 100644 index 00000000..e69de29b diff --git a/common/memcpySSE.asm b/common/src/memcpySSE.asm similarity index 100% rename from common/memcpySSE.asm rename to common/src/memcpySSE.asm diff --git a/host/IVSHMEM.cpp b/host/IVSHMEM.cpp index 9febd4ab..10b13aa9 100644 --- a/host/IVSHMEM.cpp +++ b/host/IVSHMEM.cpp @@ -21,7 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include -#include "vendor/kvm-guest-drivers-windows/ivshmem/Public.h" +#include "kvm-guest-drivers-windows/ivshmem/Public.h" #include "common/debug.h" IVSHMEM * IVSHMEM::m_instance = NULL; diff --git a/host/looking-glass-host.vcxproj b/host/looking-glass-host.vcxproj index 8b5a88f0..1b869dcf 100644 --- a/host/looking-glass-host.vcxproj +++ b/host/looking-glass-host.vcxproj @@ -169,7 +169,7 @@ Disabled ENABLE_TRACING;%(PreprocessorDefinitions) true - ..\;.\;%(AdditionalIncludeDirectories) + ..\vendor;..\common\include;.\;%(AdditionalIncludeDirectories) Windows @@ -188,7 +188,7 @@ Disabled ENABLE_TRACING;CONFIG_CAPTURE_NVFBC;%(PreprocessorDefinitions) true - ..\;.\;%(AdditionalIncludeDirectories) + ..\vendor;..\common\include;.\;%(AdditionalIncludeDirectories) Windows @@ -207,7 +207,7 @@ Disabled ENABLE_TRACING;%(PreprocessorDefinitions) true - ..\;.\;%(AdditionalIncludeDirectories) + ..\vendor;..\common\include;.\;%(AdditionalIncludeDirectories) Windows @@ -226,7 +226,7 @@ Disabled ENABLE_TRACING;CONFIG_CAPTURE_NVFBC;%(PreprocessorDefinitions) true - ..\;.\;%(AdditionalIncludeDirectories) + ..\vendor;..\common\include;.\;%(AdditionalIncludeDirectories) Windows @@ -247,7 +247,7 @@ true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - ..\;.\;%(AdditionalIncludeDirectories) + ..\vendor;..\common\include;.\;%(AdditionalIncludeDirectories) Windows @@ -271,7 +271,7 @@ true CONFIG_CAPTURE_NVFBC;%(PreprocessorDefinitions) true - ..\;.\;%(AdditionalIncludeDirectories) + ..\vendor;..\common\include;.\;%(AdditionalIncludeDirectories) Windows @@ -294,7 +294,7 @@ true NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - ..\;.\;%(AdditionalIncludeDirectories) + ..\vendor;..\common\include;.\;%(AdditionalIncludeDirectories) Windows @@ -318,7 +318,7 @@ true CONFIG_CAPTURE_NVFBC;%(PreprocessorDefinitions) true - ..\;.\;%(AdditionalIncludeDirectories) + ..\vendor;..\common\include;.\;%(AdditionalIncludeDirectories) Windows @@ -358,7 +358,7 @@ - + diff --git a/host/looking-glass-host.vcxproj.filters b/host/looking-glass-host.vcxproj.filters index 2c2248c7..9bee91ce 100644 --- a/host/looking-glass-host.vcxproj.filters +++ b/host/looking-glass-host.vcxproj.filters @@ -99,11 +99,6 @@ Header Files - - - Source Files - - Source Files\Shaders @@ -115,4 +110,9 @@ Source Files\Shaders + + + Source Files + + \ No newline at end of file diff --git a/host/main.cpp b/host/main.cpp index 89c39d41..75472048 100644 --- a/host/main.cpp +++ b/host/main.cpp @@ -22,7 +22,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include "common/debug.h" -#include "vendor/getopt/getopt.h" +#include "getopt/getopt.h" #include "CrashHandler.h" #include "TraceUtil.h"