mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 12:00:17 +02:00
Updates project to allow it to be installed
Installs as both a static library and a shared library
This commit is contained in:
1 parent
939e210a68
commit
bc294164e3
6 files changed
+113
-31
No files matched your search
+12
-2
@@ -51,6 +51,16 @@ add_subdirectory(External/SonicUtils/)
|
||||
include_directories(External/SonicUtils/include/SonicUtils)
|
||||
|
||||
add_subdirectory(Source/)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC include/)
|
||||
|
||||
add_subdirectory(Examples/)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_shared
|
||||
LIBRARY
|
||||
DESTINATION lib
|
||||
COMPONENT Libraries
|
||||
ARCHIVE
|
||||
DESTINATION lib
|
||||
COMPONENT Libraries)
|
||||
|
||||
install (DIRECTORY include/FEXCore ${CMAKE_BINARY_DIR}/include/FEXCore
|
||||
DESTINATION include
|
||||
COMPONENT Development)
|
||||
+30
-26
@@ -111,7 +111,7 @@ if (ENABLE_JITSYMBOLS)
|
||||
endif()
|
||||
|
||||
# Generate IR include file
|
||||
set(OUTPUT_NAME "${CMAKE_CURRENT_BINARY_DIR}/IRDefines.inc")
|
||||
set(OUTPUT_NAME "${CMAKE_BINARY_DIR}/include/FEXCore/IR/IRDefines.inc")
|
||||
set(INPUT_NAME "${CMAKE_CURRENT_SOURCE_DIR}/Interface/IR/IR.json")
|
||||
|
||||
add_custom_command(
|
||||
@@ -127,36 +127,40 @@ set_source_files_properties(${OUTPUT_NAME} PROPERTIES
|
||||
add_custom_target(IR_INC
|
||||
DEPENDS "${OUTPUT_NAME}")
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${SRCS})
|
||||
add_dependencies(${PROJECT_NAME} IR_INC)
|
||||
target_link_libraries(${PROJECT_NAME} LLVM pthread rt ${JIT_LIBS} dl)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE IncludePrivate/)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
"-Wno-trigraphs")
|
||||
|
||||
# Add in diagnostic colours if the option is available.
|
||||
# Ninja code generator will kill colours if this isn't here
|
||||
check_cxx_compiler_flag(-fdiagnostics-color=always GCC_COLOR)
|
||||
check_cxx_compiler_flag(-fcolor-diagnostics CLANG_COLOR)
|
||||
|
||||
if (GCC_COLOR)
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
"-fdiagnostics-color=always")
|
||||
endif()
|
||||
if (CLANG_COLOR)
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
"-fcolor-diagnostics")
|
||||
endif()
|
||||
function(AddLibrary Name Type)
|
||||
add_library(${Name} ${Type} ${SRCS})
|
||||
add_dependencies(${Name} IR_INC)
|
||||
target_link_libraries(${Name} LLVM pthread rt ${JIT_LIBS} dl)
|
||||
set_target_properties(${Name} PROPERTIES OUTPUT_NAME FEXCore)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
-Wall)
|
||||
target_include_directories(${Name} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
target_include_directories(${Name} PRIVATE IncludePrivate/)
|
||||
target_include_directories(${Name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||
|
||||
target_include_directories(${Name} PUBLIC "${PROJECT_SOURCE_DIR}/include/")
|
||||
|
||||
target_compile_options(${Name}
|
||||
PRIVATE
|
||||
-Wno-trigraphs -Wall)
|
||||
|
||||
if (GCC_COLOR)
|
||||
target_compile_options(${Name}
|
||||
PRIVATE
|
||||
"-fdiagnostics-color=always")
|
||||
endif()
|
||||
if (CLANG_COLOR)
|
||||
target_compile_options(${Name}
|
||||
PRIVATE
|
||||
"-fcolor-diagnostics")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
AddLibrary(${PROJECT_NAME} STATIC)
|
||||
AddLibrary(${PROJECT_NAME}_shared SHARED)
|
||||
add_subdirectory(Test/)
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
// Use Clang!
|
||||
#define IROP_ALLOCATE_HELPERS
|
||||
#define IROP_DISPATCH_HELPERS
|
||||
#include "IRDefines.inc"
|
||||
#include <FEXCore/IR/IRDefines.inc>
|
||||
|
||||
IRPair<IROp_Constant> _Constant(uint8_t Size, uint64_t Constant) {
|
||||
auto Op = AllocateOp<IROp_Constant, IROps::OP_CONSTANT>();
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace FEXCore::IR {
|
||||
#define IROP_GETNAME_IMPL
|
||||
#define IROP_GETRAARGS_IMPL
|
||||
|
||||
#include "IRDefines.inc"
|
||||
#include <FEXCore/IR/IRDefines.inc>
|
||||
|
||||
static void PrintArg(std::stringstream *out, [[maybe_unused]] IRListView<false> const* IR, uint64_t Arg) {
|
||||
*out << "0x" << std::hex << Arg;
|
||||
|
||||
@@ -332,7 +332,7 @@ struct CondClassType final {
|
||||
#define IROP_ENUM
|
||||
#define IROP_STRUCTS
|
||||
#define IROP_SIZES
|
||||
#include "IRDefines.inc"
|
||||
#include <FEXCore/IR/IRDefines.inc>
|
||||
|
||||
template<bool>
|
||||
class IRListView;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
class Event final {
|
||||
private:
|
||||
/**
|
||||
* @brief Literally just an atomic bool that we are using for this class
|
||||
*/
|
||||
class Flag final {
|
||||
public:
|
||||
bool TestAndSet(bool SetValue = true) {
|
||||
bool Expected = !SetValue;
|
||||
return Value.compare_exchange_strong(Expected, SetValue);
|
||||
}
|
||||
|
||||
bool TestAndClear() {
|
||||
return TestAndSet(false);
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic_bool Value {false};
|
||||
};
|
||||
|
||||
public:
|
||||
~Event() {
|
||||
NotifyAll();
|
||||
}
|
||||
void NotifyOne() {
|
||||
if (FlagObject.TestAndSet()) {
|
||||
std::lock_guard<std::mutex> lk(MutexObject);
|
||||
CondObject.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyAll() {
|
||||
if (FlagObject.TestAndSet()) {
|
||||
std::lock_guard<std::mutex> lk(MutexObject);
|
||||
CondObject.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
void Wait() {
|
||||
// Have we signaled before we started waiting?
|
||||
if (FlagObject.TestAndClear())
|
||||
return;
|
||||
|
||||
std::unique_lock<std::mutex> lk(MutexObject);
|
||||
CondObject.wait(lk, [this]{ return FlagObject.TestAndClear(); });
|
||||
}
|
||||
|
||||
template<class Rep, class Period>
|
||||
bool WaitFor(std::chrono::duration<Rep, Period> const& time) {
|
||||
// Have we signaled before we started waiting?
|
||||
if (FlagObject.TestAndClear())
|
||||
return true;
|
||||
|
||||
std::unique_lock<std::mutex> lk(MutexObject);
|
||||
bool DidSignal = CondObject.wait_for(lk, time, [this]{ return FlagObject.TestAndClear(); });
|
||||
return DidSignal;
|
||||
}
|
||||
|
||||
private:
|
||||
Flag FlagObject;
|
||||
std::mutex MutexObject;
|
||||
std::condition_variable CondObject;
|
||||
};
|
||||
Reference in new issue
Block a user