From 831c8b91894cc27b12ae74c7d04db3459e789a85 Mon Sep 17 00:00:00 2001 From: kojin Date: Thu, 2 Sep 2021 12:36:36 -0400 Subject: [PATCH] common: fix cmake on win32 --- CMakeLists.txt | 3 +- common/CMakeLists.txt | 167 ++++++++++-------- common/Windows/WinHostSys.cpp | 3 + common/Windows/WinThreads.cpp | 8 +- common/common.vcxproj | 4 +- common/emitter/CMakeLists.txt | 68 ------- common/emitter/WinCpuDetect.cpp | 3 + common/x86/MemcpyFast.cpp | 3 +- pcsx2/CMakeLists.txt | 3 +- pcsx2/DEV9/ATA/ATA.h | 2 +- tests/ctest/CMakeLists.txt | 2 +- tests/ctest/x86emitter/codegen_tests.cpp | 4 +- tests/ctest/x86emitter/codegen_tests.h | 2 +- tests/ctest/x86emitter/codegen_tests_main.cpp | 2 +- 14 files changed, 108 insertions(+), 166 deletions(-) delete mode 100644 common/emitter/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d07a76cc0..37ec70818f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,8 +42,7 @@ if(NOT NO_TRANSLATION) endif() # make common -add_subdirectory(common/src/Utilities) -add_subdirectory(common/src/x86emitter) +add_subdirectory(common) # make pcsx2 add_subdirectory(pcsx2) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 151b0a6b8c..3cbe3cdbae 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -5,13 +5,13 @@ if(NOT TOP_CMAKE_WAS_SOURCED) It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt") endif(NOT TOP_CMAKE_WAS_SOURCED) -add_library(Utilities) +add_library(common) -# Utilities sources -target_sources(Utilities PRIVATE +# x86emitter sources +target_sources(common PRIVATE VirtualMemory.cpp - ../../include/Utilities/EventSource.inl - ../../include/Utilities/SafeArray.inl + EventSource.inl + SafeArray.inl CheckedStaticBox.cpp Console.cpp EventSource.cpp @@ -29,89 +29,102 @@ target_sources(Utilities PRIVATE pxTranslate.cpp pxWindowTextWriter.cpp RwMutex.cpp + Semaphore.cpp StringHelpers.cpp ThreadingDialogs.cpp ThreadTools.cpp wxAppWithHelpers.cpp wxGuiTools.cpp wxHelpers.cpp -) + emitter/bmi.cpp + emitter/cpudetect.cpp + emitter/fpu.cpp + emitter/groups.cpp + emitter/jmp.cpp + emitter/legacy.cpp + emitter/legacy_sse.cpp + emitter/movs.cpp + emitter/simd.cpp + emitter/WinCpuDetect.cpp + emitter/x86emitter.cpp + x86/MemcpyFast.cpp + Windows/WinThreads.cpp + Windows/WinHostSys.cpp + Windows/WinMisc.cpp) -# Utilities headers -target_sources(Utilities PRIVATE - ../../include/Utilities/Assertions.h - ../../include/Utilities/boost_spsc_queue.hpp - ../../include/Utilities/CheckedStaticBox.h - ../../include/Utilities/Console.h - ../../include/Utilities/Dependencies.h - ../../include/Utilities/EventSource.h - ../../include/Utilities/Exceptions.h - ../../include/Utilities/General.h - ../../include/Utilities/MemcpyFast.h - ../../include/Utilities/MemsetFast.inl - ../../include/Utilities/Path.h - ../../include/Utilities/PageFaultSource.h - ../../include/Utilities/pxCheckBox.h - ../../include/Utilities/pxForwardDefs.h - ../../include/Utilities/pxRadioPanel.h - ../../include/Utilities/pxStaticText.h - ../../include/Utilities/pxStreams.h - ../../include/Utilities/RedtapeWindows.h - ../../include/Utilities/RwMutex.h - ../../include/Utilities/SafeArray.h - ../../include/Utilities/ScopedAlloc.h - ../../include/Utilities/ScopedPtrMT.h - ../../include/Utilities/StringHelpers.h - ../../include/Utilities/Threading.h - ../../include/Utilities/ThreadingDialogs.h - ../../include/Utilities/TraceLog.h - ../../include/Utilities/wxAppWithHelpers.h - ../../include/Utilities/wxBaseTools.h - ../../include/Utilities/wxGuiTools.h +# x86emitter headers +target_sources(common PRIVATE + Assertions.h + boost_spsc_queue.hpp + CheckedStaticBox.h + Console.h + Dependencies.h + EventSource.h + Exceptions.h + General.h + MemcpyFast.h + MemsetFast.inl + Path.h + PageFaultSource.h PrecompiledHeader.h - ThreadingInternal.h -) - -if(WIN32) - target_sources(Utilities PRIVATE - Windows/WinThreads.cpp - Windows/WinHostSys.cpp - Windows/WinMisc.cpp - Semaphore.cpp + pxCheckBox.h + pxForwardDefs.h + pxRadioPanel.h + pxStaticText.h + pxStreams.h + RedtapeWindows.h + RwMutex.h + SafeArray.h + ScopedAlloc.h + ScopedPtrMT.h + StringHelpers.h + Threading.h + ThreadingDialogs.h + TraceLog.h + wxAppWithHelpers.h + wxBaseTools.h + wxGuiTools.h + emitter/cpudetect_internal.h + emitter/implement/dwshift.h + emitter/implement/group1.h + emitter/implement/group2.h + emitter/implement/group3.h + emitter/implement/helpers.h + emitter/implement/incdec.h + emitter/implement/jmpcall.h + emitter/implement/movs.h + emitter/implement/simd_arithmetic.h + emitter/implement/simd_comparisons.h + emitter/implement/simd_helpers.h + emitter/implement/simd_moremovs.h + emitter/implement/simd_shufflepack.h + emitter/implement/simd_templated_helpers.h + emitter/implement/test.h + emitter/implement/xchg.h + emitter/instructions.h + emitter/internal.h + emitter/legacy_instructions.h + emitter/legacy_internal.h + emitter/legacy_types.h + emitter/tools.h + emitter/x86emitter.h + emitter/x86types.h ) - if(_M_X86_32) - target_sources(Utilities PRIVATE x86/MemcpyFast.cpp) - endif() - target_link_libraries(Utilities PUBLIC pthreads4w Winmm.lib) -else() - target_sources(Utilities PRIVATE - AlignedMalloc.cpp - Linux/LnxHostSys.cpp - ) - if(APPLE) - target_sources(Utilities PRIVATE - Darwin/DarwinThreads.cpp - Darwin/DarwinMisc.cpp - Darwin/DarwinSemaphore.cpp - ) - else() - target_sources(Utilities PRIVATE - Linux/LnxThreads.cpp - Linux/LnxMisc.cpp - Semaphore.cpp - ) - endif() -endif() if(USE_VTUNE) - target_link_libraries(Utilities PUBLIC Vtune::Vtune) + target_link_libraries(common PUBLIC Vtune::Vtune) endif() -target_link_libraries(Utilities PRIVATE ${LIBC_LIBRARIES} PUBLIC wxWidgets::all) -target_compile_features(Utilities PUBLIC cxx_std_17) -target_include_directories(Utilities PUBLIC ../../../3rdparty/include ../../include PRIVATE ../../include/Utilities .) -target_compile_definitions(Utilities PUBLIC "${PCSX2_DEFS}") -target_compile_options(Utilities PRIVATE "${PCSX2_WARNINGS}") -if(COMMAND target_precompile_headers) - target_precompile_headers(Utilities PRIVATE PrecompiledHeader.h) +if(WIN32) + target_link_libraries(common PUBLIC pthreads4w Winmm.lib) +endif() + +target_link_libraries(common PRIVATE ${LIBC_LIBRARIES} PUBLIC wxWidgets::all) +target_compile_features(common PUBLIC cxx_std_17) +target_include_directories(common PUBLIC ../3rdparty/include ../) +target_compile_definitions(common PUBLIC "${PCSX2_DEFS}") +target_compile_options(common PRIVATE "${PCSX2_WARNINGS}") + +if(COMMAND target_precompile_headers) + target_precompile_headers(common PRIVATE PrecompiledHeader.h) endif() diff --git a/common/Windows/WinHostSys.cpp b/common/Windows/WinHostSys.cpp index 4f666a22ed..eeec61ee7c 100644 --- a/common/Windows/WinHostSys.cpp +++ b/common/Windows/WinHostSys.cpp @@ -13,6 +13,8 @@ * If not, see . */ +#if defined(_WIN32) + #include "common/RedtapeWindows.h" #include "common/PageFaultSource.h" @@ -148,3 +150,4 @@ void HostSys::MemProtect(void *baseaddr, size_t size, const PageProtectionMode & pxFailDev(apiError.FormatDiagnosticMessage()); } } +#endif diff --git a/common/Windows/WinThreads.cpp b/common/Windows/WinThreads.cpp index 08d06b8b9d..05e93e3eb9 100644 --- a/common/Windows/WinThreads.cpp +++ b/common/Windows/WinThreads.cpp @@ -13,16 +13,12 @@ * If not, see . */ +#if defined(_WIN32) + #include "common/RedtapeWindows.h" #include "common/PersistentThread.h" #include "common/emitter/tools.h" -#ifndef __WXMSW__ - -#pragma message("WinThreads.cpp should only be compiled by projects or makefiles targeted at Microsoft Windows.") - -#else - __fi void Threading::Sleep(int ms) { ::Sleep(ms); diff --git a/common/common.vcxproj b/common/common.vcxproj index 3d6c7e09ec..b0dad8a215 100644 --- a/common/common.vcxproj +++ b/common/common.vcxproj @@ -50,9 +50,7 @@ - - true - + diff --git a/common/emitter/CMakeLists.txt b/common/emitter/CMakeLists.txt deleted file mode 100644 index 98300f6ff0..0000000000 --- a/common/emitter/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Check that people use the good file -if(NOT TOP_CMAKE_WAS_SOURCED) - message(FATAL_ERROR " - You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir. - It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt") -endif(NOT TOP_CMAKE_WAS_SOURCED) - -add_library(x86emitter) - -# x86emitter sources -target_sources(x86emitter PRIVATE - bmi.cpp - cpudetect.cpp - fpu.cpp - groups.cpp - jmp.cpp - legacy.cpp - legacy_sse.cpp - movs.cpp - PrecompiledHeader.cpp - simd.cpp - x86emitter.cpp) - -# x86emitter headers -target_sources(x86emitter PRIVATE - ../../include/x86emitter/implement/dwshift.h - ../../include/x86emitter/implement/group1.h - ../../include/x86emitter/implement/group2.h - ../../include/x86emitter/implement/group3.h - ../../include/x86emitter/implement/helpers.h - ../../include/x86emitter/implement/incdec.h - ../../include/x86emitter/implement/jmpcall.h - ../../include/x86emitter/implement/movs.h - ../../include/x86emitter/implement/simd_arithmetic.h - ../../include/x86emitter/implement/simd_comparisons.h - ../../include/x86emitter/implement/simd_helpers.h - ../../include/x86emitter/implement/simd_moremovs.h - ../../include/x86emitter/implement/simd_shufflepack.h - ../../include/x86emitter/implement/simd_templated_helpers.h - ../../include/x86emitter/implement/test.h - ../../include/x86emitter/implement/xchg.h - ../../include/x86emitter/instructions.h - ../../include/x86emitter/internal.h - ../../include/x86emitter/legacy_instructions.h - ../../include/x86emitter/legacy_internal.h - ../../include/x86emitter/legacy_types.h - ../../include/x86emitter/tools.h - ../../include/x86emitter/x86emitter.h - ../../include/x86emitter/x86types.h - PrecompiledHeader.h - cpudetect_internal.h - ) - -if(Windows) - target_sources(x86emitter PRIVATE WinCpuDetect.cpp) -else() - target_sources(x86emitter PRIVATE LnxCpuDetect.cpp) -endif() - -target_link_libraries(x86emitter PRIVATE Utilities wxWidgets::all) -target_compile_features(x86emitter PUBLIC cxx_std_17) -target_include_directories(x86emitter PUBLIC ../../include PRIVATE ../../include/x86emitter) -target_compile_definitions(x86emitter PUBLIC "${PCSX2_DEFS}") -target_compile_options(x86emitter PRIVATE "${PCSX2_WARNINGS}") - -if(COMMAND target_precompile_headers) - target_precompile_headers(x86emitter PRIVATE PrecompiledHeader.h) -endif() diff --git a/common/emitter/WinCpuDetect.cpp b/common/emitter/WinCpuDetect.cpp index 1976f58e2f..e5f3e4dab9 100644 --- a/common/emitter/WinCpuDetect.cpp +++ b/common/emitter/WinCpuDetect.cpp @@ -13,6 +13,8 @@ * If not, see . */ +#if defined(_WIN32) + #include "common/Console.h" #include "common/emitter/cpudetect_internal.h" @@ -79,3 +81,4 @@ SingleCoreAffinity::~SingleCoreAffinity() if (s_oldmask != ERROR_INVALID_PARAMETER) SetThreadAffinityMask(s_threadId, s_oldmask); } +#endif diff --git a/common/x86/MemcpyFast.cpp b/common/x86/MemcpyFast.cpp index 9d6be915d3..9a9b4d2de9 100644 --- a/common/x86/MemcpyFast.cpp +++ b/common/x86/MemcpyFast.cpp @@ -1,6 +1,7 @@ // GH: AMD memcpy was removed. The remaining part (memcmp_mmx) is likely from Zerofrog. // Hopefully memcmp_mmx will be dropped in the future. +#if defined(_WIN32) && !defined(_M_AMD64) #include "common/MemcpyFast.h" #include "common/Assertions.h" @@ -10,8 +11,6 @@ // Inline assembly syntax for use with Visual C++ -#if defined(_MSC_VER) - // mmx mem-compare implementation, size has to be a multiple of 8 // returns 0 is equal, nonzero value if not equal // ~10 times faster than standard memcmp diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index d63669e0de..85957fc873 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -1426,8 +1426,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBS endif() target_link_libraries(PCSX2 PRIVATE - Utilities - x86emitter + common fmt::fmt yaml-cpp chdr-static diff --git a/pcsx2/DEV9/ATA/ATA.h b/pcsx2/DEV9/ATA/ATA.h index 0c3c933fff..d597edd8ec 100644 --- a/pcsx2/DEV9/ATA/ATA.h +++ b/pcsx2/DEV9/ATA/ATA.h @@ -20,7 +20,7 @@ #include #include #include -#include "ghc/filesystem.h" +#include #include #include "DEV9/SimpleQueue.h" diff --git a/tests/ctest/CMakeLists.txt b/tests/ctest/CMakeLists.txt index 27d6c5c708..30f5a09429 100644 --- a/tests/ctest/CMakeLists.txt +++ b/tests/ctest/CMakeLists.txt @@ -65,7 +65,7 @@ add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND}) macro(add_pcsx2_test target) add_executable(${target} EXCLUDE_FROM_ALL ${ARGN}) - target_link_libraries(${target} PRIVATE x86emitter gtest_main Utilities) + target_link_libraries(${target} PRIVATE gtest_main common) add_dependencies(unittests ${target}) add_test(NAME ${target} COMMAND ${target}) endmacro() diff --git a/tests/ctest/x86emitter/codegen_tests.cpp b/tests/ctest/x86emitter/codegen_tests.cpp index 4baed86c61..b17a7a4e10 100644 --- a/tests/ctest/x86emitter/codegen_tests.cpp +++ b/tests/ctest/x86emitter/codegen_tests.cpp @@ -15,8 +15,8 @@ #include "codegen_tests.h" #include -#include -#include +#include +#include using namespace x86Emitter; diff --git a/tests/ctest/x86emitter/codegen_tests.h b/tests/ctest/x86emitter/codegen_tests.h index 5b42d53c4e..71b1902f0d 100644 --- a/tests/ctest/x86emitter/codegen_tests.h +++ b/tests/ctest/x86emitter/codegen_tests.h @@ -13,7 +13,7 @@ * If not, see . */ -#include "Utilities/Dependencies.h" +#include "common/Dependencies.h" void runCodegenTest(void (*exec)(void *base), const char* description, const char* expected); diff --git a/tests/ctest/x86emitter/codegen_tests_main.cpp b/tests/ctest/x86emitter/codegen_tests_main.cpp index 14da78bc9c..a64c15df91 100644 --- a/tests/ctest/x86emitter/codegen_tests_main.cpp +++ b/tests/ctest/x86emitter/codegen_tests_main.cpp @@ -15,7 +15,7 @@ #include "codegen_tests.h" #include -#include +#include #include using namespace x86Emitter;