common: fix cmake on win32

This commit is contained in:
kojin 2021-09-02 12:36:36 -04:00 committed by Kojin
parent 8fdaaa2eab
commit 831c8b9189
14 changed files with 108 additions and 166 deletions

View File

@ -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)

View File

@ -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()

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -13,16 +13,12 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#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);

View File

@ -50,9 +50,7 @@
<ClCompile Include="pxWindowTextWriter.cpp" />
<ClCompile Include="ThreadingDialogs.cpp" />
<ClCompile Include="VirtualMemory.cpp" />
<ClCompile Include="x86\MemcpyFast.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="x86\MemcpyFast.cpp" />
<ClCompile Include="PathUtils.cpp" />
<ClCompile Include="Perf.cpp" />
<ClCompile Include="PrecompiledHeader.cpp">

View File

@ -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()

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -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

View File

@ -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

View File

@ -20,7 +20,7 @@
#include <atomic>
#include <mutex>
#include <condition_variable>
#include "ghc/filesystem.h"
#include <ghc/filesystem.h>
#include <fstream>
#include "DEV9/SimpleQueue.h"

View File

@ -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()

View File

@ -15,8 +15,8 @@
#include "codegen_tests.h"
#include <gtest/gtest.h>
#include <x86emitter/x86emitter.h>
#include <Utilities/Assertions.h>
#include <common/emitter/x86emitter.h>
#include <common/Assertions.h>
using namespace x86Emitter;

View File

@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "Utilities/Dependencies.h"
#include "common/Dependencies.h"
void runCodegenTest(void (*exec)(void *base), const char* description, const char* expected);

View File

@ -15,7 +15,7 @@
#include "codegen_tests.h"
#include <gtest/gtest.h>
#include <x86emitter/x86emitter.h>
#include <common/emitter/x86emitter.h>
#include <cstdio>
using namespace x86Emitter;