diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dbda02..b9aaa26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,37 +31,15 @@ if (APPLE) set(APP_LIBDIR AkVirtualCamera.plugin/Contents/Frameworks) set(MAIN_EXECUTABLE AkVirtualCamera.plugin/Contents/MacOS/AkVirtualCamera) set(PACKET_HIDE_ARCH false) - - if (IS_ARM_TARGET) - if (IS_64BITS_TARGET) - set(PACKET_TARGET_ARCH arm64) - else () - set(PACKET_TARGET_ARCH arm32) - endif() - else () - if (IS_64BITS_TARGET) - set(PACKET_TARGET_ARCH x64) - else () - set(PACKET_TARGET_ARCH x86) - endif() - endif() - set(QTIFW_TARGET_DIR "\@ApplicationsDir\@/AkVirtualCamera") set(OUTPUT_FORMATS "MacPkg") elseif (WIN32) add_subdirectory(dshow) set(TARGET_PLATFORM windows) set(BUILD_INFO_FILE share/build-info.txt) - set(MAIN_EXECUTABLE ${TARGET_ARCH}/AkVCamManager.exe) - set(APP_LIBDIR ${TARGET_ARCH}) + set(MAIN_EXECUTABLE ${WIN_TARGET_ARCH}/AkVCamManager.exe) + set(APP_LIBDIR ${WIN_TARGET_ARCH}) set(PACKET_HIDE_ARCH true) - - if (IS_64BITS_TARGET) - set(PACKET_TARGET_ARCH win64) - else () - set(PACKET_TARGET_ARCH win32) - endif() - set(OUTPUT_FORMATS "Nsis") endif () diff --git a/Manager/CMakeLists.txt b/Manager/CMakeLists.txt index a4bdfd4..8c0d10f 100644 --- a/Manager/CMakeLists.txt +++ b/Manager/CMakeLists.txt @@ -28,7 +28,7 @@ if (APPLE) set(INSTALLPATH ${CMIO_PLUGIN_NAME}.plugin/Contents/Resources) elseif (WIN32) include(../dshow/dshow.cmake) - set(INSTALLPATH ${TARGET_ARCH}) + set(INSTALLPATH ${WIN_TARGET_ARCH}) endif () add_executable(Manager diff --git a/commons.cmake b/commons.cmake index e426128..95e7076 100644 --- a/commons.cmake +++ b/commons.cmake @@ -39,45 +39,10 @@ add_definitions(-DCOMMONS_APPNAME="${COMMONS_APPNAME}" -DCOMMONS_VERSION="${VERSION}" -DPREFIX="${PREFIX}") -if (APPLE) - check_cxx_source_compiles(" - #ifndef __arm__ - #error Not ARM - #endif - - int main() - { - return 0; - }" IS_ARM_TARGET) - check_cxx_source_compiles(" - #ifndef __x86_64__ - #error Not x64 - #endif - - int main() - { - return 0; - }" IS_64BITS_TARGET) -elseif (WIN32) - check_cxx_source_compiles(" - #ifndef _WIN64 - #error Not x64 - #endif - - int main() - { - return 0; - }" IS_64BITS_TARGET) - +if (WIN32) add_definitions(-DUNICODE -D_UNICODE) endif () -if (IS_64BITS_TARGET) - set(TARGET_ARCH x64 CACHE INTERNAL "") -else () - set(TARGET_ARCH x86 CACHE INTERNAL "") -endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -static-libgcc -static-libstdc++") endif() @@ -85,3 +50,152 @@ endif() if (DAILY_BUILD) add_definitions(-DDAILY_BUILD) endif () + +# NOTE for other developers: TARGET_ARCH is intended to be used as a reference +# for the deploy tool, so don't rush on adding new architectures unless you +# want to create a binary distributable for that architecture. +# Webcamoid build is not affected in anyway by the value of TARGET_ARCH, if the +# build fails its something else and totally unrelated to that variable. + +if (WIN32) + include(CheckCXXSourceCompiles) + check_cxx_source_compiles(" + #include + + #ifndef _M_X64 + #error Not WIN64 + #endif + + int main() + { + return 0; + }" IS_WIN64_TARGET) + + check_cxx_source_compiles(" + #include + + #ifndef _M_IX86 + #error Not WIN32 + #endif + + int main() + { + return 0; + }" IS_WIN32_TARGET) + + check_cxx_source_compiles(" + #include + + #ifndef _M_ARM64 + #error Not ARM64 + #endif + + int main() + { + return 0; + }" IS_WIN64_ARM_TARGET) + + check_cxx_source_compiles(" + #include + + #ifndef _M_ARM + #error Not ARM + #endif + + int main() + { + return 0; + }" IS_WIN32_ARM_TARGET) + + if (IS_WIN64_TARGET OR IS_WIN64_ARM_TARGET) + set(QTIFW_TARGET_DIR "\@ApplicationsDirX64\@/Webcamoid") + else () + set(QTIFW_TARGET_DIR "\@ApplicationsDirX86\@/Webcamoid") + endif() + + if (IS_WIN64_TARGET) + set(TARGET_ARCH win64) + set(WIN_TARGET_ARCH x64) + elseif (IS_WIN64_ARM_TARGET) + set(TARGET_ARCH win64_arm) + set(WIN_TARGET_ARCH arm64) + elseif (IS_WIN32_TARGET) + set(TARGET_ARCH win32) + set(WIN_TARGET_ARCH x86) + elseif (IS_WIN32_ARM_TARGET) + set(TARGET_ARCH win32_arm) + set(WIN_TARGET_ARCH arm32) + else () + set(TARGET_ARCH unknown) + set(WIN_TARGET_ARCH unknown) + endif() +elseif (UNIX) + if (ANDROID) + set(TARGET_ARCH ${CMAKE_ANDROID_ARCH_ABI}) + else () + include(CheckCXXSourceCompiles) + check_cxx_source_compiles(" + #ifndef __x86_64__ + #error Not x64 + #endif + + int main() + { + return 0; + }" IS_X86_64_TARGET) + + check_cxx_source_compiles(" + #ifndef __i386__ + #error Not x86 + #endif + + int main() + { + return 0; + }" IS_I386_TARGET) + + check_cxx_source_compiles(" + #ifndef __aarch64__ + #error Not ARM64 + #endif + + int main() + { + return 0; + }" IS_ARM64_TARGET) + + check_cxx_source_compiles(" + #ifndef __arm__ + #error Not ARM + #endif + + int main() + { + return 0; + }" IS_ARM_TARGET) + + check_cxx_source_compiles(" + #ifndef __riscv + #error Not RISC-V + #endif + + int main() + { + return 0; + }" IS_RISCV_TARGET) + + if (IS_X86_64_TARGET) + set(TARGET_ARCH x64) + elseif (IS_I386_TARGET) + set(TARGET_ARCH x86) + elseif (IS_ARM64_TARGET) + set(TARGET_ARCH arm64) + elseif (IS_ARM_TARGET) + set(TARGET_ARCH arm32) + elseif (IS_RISCV_TARGET) + set(TARGET_ARCH riscv) + else () + set(TARGET_ARCH unknown) + endif () + endif () +endif () diff --git a/dshow/Assistant/CMakeLists.txt b/dshow/Assistant/CMakeLists.txt index 70a050a..db2c53d 100644 --- a/dshow/Assistant/CMakeLists.txt +++ b/dshow/Assistant/CMakeLists.txt @@ -24,7 +24,7 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) include(../dshow.cmake) -set(INSTALLPATH ${TARGET_ARCH}) +set(INSTALLPATH ${WIN_TARGET_ARCH}) add_executable(Assistant src/main.cpp diff --git a/dshow/VirtualCamera/CMakeLists.txt b/dshow/VirtualCamera/CMakeLists.txt index bd19c8c..92705b6 100644 --- a/dshow/VirtualCamera/CMakeLists.txt +++ b/dshow/VirtualCamera/CMakeLists.txt @@ -25,7 +25,7 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) include(../dshow.cmake) -set(INSTALLPATH ${TARGET_ARCH}) +set(INSTALLPATH ${WIN_TARGET_ARCH}) add_library(VirtualCamera SHARED src/basefilter.cpp diff --git a/package_info.conf.in b/package_info.conf.in index 273da75..09b526e 100644 --- a/package_info.conf.in +++ b/package_info.conf.in @@ -5,7 +5,7 @@ sourcesDir = @CMAKE_SOURCE_DIR@ mainExecutable = @MAIN_EXECUTABLE@ libDir = @APP_LIBDIR@ buildInfoFile = @BUILD_INFO_FILE@ -targetArch = @PACKET_TARGET_ARCH@ +targetArch = @TARGET_ARCH@ version = @VERSION@ outputFormats = @OUTPUT_FORMATS@ hideArch = @PACKET_HIDE_ARCH@