cmake_minimum_required(VERSION 3.18.4) set(IS_OS_WINDOWS FALSE) set(IS_OS_LINUX FALSE) set(IS_OS_MAC FALSE) set(IS_ARCH_AMD64 FALSE) set(IS_ARCH_X86 FALSE) set(IS_ARCH_ARM64 FALSE) set(IS_ARCH_ARM FALSE) project(EHS CXX C) if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") set(IS_OS_WINDOWS TRUE) set(USER_HOME_DIRECTORY $ENV{USERPROFILE}) message("Building for the Windows operating system.") elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") set(IS_OS_LINUX TRUE) set(USER_HOME_DIRECTORY $ENV{HOME}) add_compile_options(-Wno-stringop-overflow) message("Building for the Linux operating system.") elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") set(IS_OS_MAC TRUE) set(USER_HOME_DIRECTORY $ENV{HOME}) message("Building for the Mac operating system.") endif () if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") set(IS_ARCH_AMD64 TRUE) enable_language(ASM_NASM) message("Building for the AMD64 architecture.") elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64") set(IS_ARCH_ARM64 TRUE) enable_language(ASM) message("Building for the ARM64 architecture.") endif () set(CMAKE_CXX_STANDARD 20) set(EHS_SOURCES src/EHS.cpp include/EHS.h src/Type.cpp include/Type.h src/BaseObj.cpp include/BaseObj.h src/GarbageCollector.cpp include/GarbageCollector.h src/Log.cpp include/Log.h src/URI.cpp include/URI.h src/Math.cpp include/Math.h src/Color4.cpp include/Color4.h src/Color3.cpp include/Color3.h src/Version.cpp include/Version.h src/Base64.cpp include/Base64.h src/Data.cpp include/Data.h src/Range.cpp include/Range.h src/Util.cpp include/Util.h src/Task.cpp include/Task.h src/DataType.cpp include/DataType.h src/Encryption.cpp include/Encryption.h include/Anchor.h include/Dock.h include/HashMap.h include/HRNG.h include/Link.h include/LinkedList.h include/Mat2.h include/Mat3.h include/Mat4.h include/PRNG.h include/Quat.h include/Rect.h include/Str.h include/Types.h include/UTF.h include/Vec2.h include/Vec3.h include/Vec4.h include/Serializer.h include/Array.h include/Vector.h include/SArray.h src/PtrData.cpp include/PtrData.h include/UniPtr.h include/ShdPtr.h include/WkPtr.h src/Database/DVar.cpp include/Database/DVar.h src/System/CPU.cpp include/System/CPU.h src/System/Thread.cpp include/System/Thread.h src/System/BaseMutex.cpp include/System/BaseMutex.h src/System/BaseSemaphore.cpp include/System/BaseSemaphore.h src/System/BaseSystem.cpp include/System/BaseSystem.h src/System/BaseOpen.cpp include/System/BaseOpen.h include/System/Architecture.h include/System/Mutex.h include/System/Open.h include/System/OS.h include/System/Semaphore.h include/System/System.h src/Json/Json.cpp include/Json/Json.h src/Json/JsonBase.cpp include/Json/JsonBase.h src/Json/JsonNum.cpp include/Json/JsonNum.h src/Json/JsonBool.cpp include/Json/JsonBool.h src/Json/JsonStr.cpp include/Json/JsonStr.h src/Json/JsonObj.cpp include/Json/JsonObj.h src/Json/JsonArray.cpp include/Json/JsonArray.h src/Json/JsonVar.cpp include/Json/JsonVar.h src/IO/Console.cpp include/IO/Console.h src/IO/RIFF_Chunk.cpp include/IO/RIFF_Chunk.h src/IO/RIFF.cpp include/IO/RIFF.h src/IO/BaseWindow.cpp include/IO/BaseWindow.h src/IO/BaseFile.cpp include/IO/BaseFile.h src/IO/Glyph.cpp include/IO/Glyph.h src/IO/FontAtlas.cpp include/IO/FontAtlas.h src/IO/BaseFileMonitor.cpp include/IO/BaseFileMonitor.h include/IO/COM.h include/IO/File.h include/IO/FileMonitor.h include/IO/Window.h src/IO/Socket/Request.cpp include/IO/Socket/Request.h src/IO/Socket/Response.cpp include/IO/Socket/Response.h src/IO/Socket/DNS.cpp include/IO/Socket/DNS.h src/IO/Socket/BaseUDP.cpp include/IO/Socket/BaseUDP.h src/IO/Socket/BaseTCP.cpp include/IO/Socket/BaseTCP.h src/IO/Socket/Comms.cpp include/IO/Socket/Comms.h src/IO/Socket/CommsSystem.cpp include/IO/Socket/CommsSystem.h src/IO/Socket/Operation.cpp include/IO/Socket/Operation.h src/IO/Socket/Fragments.cpp include/IO/Socket/Fragments.h src/IO/Socket/Endpoint.cpp include/IO/Socket/Endpoint.h src/IO/Socket/SSL.cpp include/IO/Socket/SSL.h src/IO/Socket/RestAPIs/Twitch.cpp include/IO/Socket/RestAPIs/Twitch.h src/IO/Socket/RestAPIs/TwitchChat.cpp include/IO/Socket/RestAPIs/TwitchChat.h src/IO/Socket/RestAPIs/Spotify.cpp include/IO/Socket/RestAPIs/Spotify.h include/IO/Socket/Socket.h include/IO/Socket/TCP.h include/IO/Socket/UDP.h include/IO/Socket/Utils.h src/IO/Audio/Audio.cpp include/IO/Audio/Audio.h src/IO/Audio/BaseAudioDevice.cpp include/IO/Audio/BaseAudioDevice.h src/IO/Audio/AudioCodec.cpp include/IO/Audio/AudioCodec.h include/IO/Audio/AudioDevice.h src/IO/Img/PNG.cpp include/IO/Img/PNG.h src/IO/Img/Img.cpp include/IO/Img/Img.h src/IO/Img/PNG_Chunk.cpp include/IO/Img/PNG_Chunk.h src/IO/Img/ImgCodec.cpp include/IO/Img/ImgCodec.h include/IO/Model/Vertex.h src/IO/Model/Mesh.cpp include/IO/Model/Mesh.h src/IO/Model/Bone.cpp include/IO/Model/Bone.h src/IO/Model/Model.cpp include/IO/Model/Model.h src/IO/Model/Animation.cpp include/IO/Model/Animation.h src/IO/Model/AnimBone.cpp include/IO/Model/AnimBone.h src/IO/Model/KeyFrame.cpp include/IO/Model/KeyFrame.h src/IO/Model/PropertyChange.cpp include/IO/Model/PropertyChange.h src/IO/HID/ButtonState.cpp include/IO/HID/ButtonState.h src/IO/HID/Button.cpp include/IO/HID/Button.h src/IO/HID/Mouse.cpp include/IO/HID/Mouse.h src/IO/HID/Keyboard.cpp include/IO/HID/Keyboard.h src/IO/HID/HID.cpp include/IO/HID/HID.h src/IO/HID/InputHandler.cpp include/IO/HID/InputHandler.h src/IO/HID/Input.cpp include/IO/HID/Input.h ) if (IS_OS_WINDOWS) list(APPEND EHS_SOURCES src/IO/Socket/UDP_W32.cpp include/IO/Socket/UDP_W32.h src/IO/Socket/TCP_W32.cpp include/IO/Socket/TCP_W32.h src/System/Semaphore_W32.cpp include/System/Semaphore_W32.h src/System/System_W32.cpp include/System/System_W32.h src/System/Mutex_W32.cpp include/System/Mutex_W32.h src/System/Open_W32.cpp include/System/Open_W32.h src/IO/Audio/AudioDevice_W32.cpp include/IO/Audio/AudioDevice_W32.h src/IO/MsgBox.cpp include/IO/MsgBox.h src/IO/File_W32.cpp include/IO/File_W32.h src/IO/FileMonitor_W32.cpp include/IO/FileMonitor_W32.h src/IO/Window_W32.cpp include/IO/Window_W32.h src/IO/COM.cpp include/IO/COM.h src/System/CPU_MSVC_AMD64.asm src/HRNG_MSVC.asm src/Math_MSVC_AMD64.asm ) elseif (IS_OS_LINUX) list(APPEND EHS_SOURCES src/IO/Socket/UDP_BSD.cpp include/IO/Socket/UDP_BSD.h src/IO/Socket/TCP_BSD.cpp include/IO/Socket/TCP_BSD.h src/System/Semaphore_P.cpp include/System/Semaphore_P.h src/System/System_LNX.cpp include/System/System_LNX.h src/System/Open_UNX.cpp include/System/Open_UNX.h src/IO/File_UNX.cpp include/IO/File_UNX.h src/IO/FileMonitor_UNX.cpp include/IO/FileMonitor_UNX.h src/System/Mutex_PT.cpp include/System/Mutex_PT.h src/IO/Audio/AudioDevice_ALSA.cpp include/IO/Audio/AudioDevice_ALSA.h src/System/FileSystem.cpp include/System/FileSystem.h src/System/User.cpp include/System/User.h ) set(LINUX_WINDOW_SYSTEM "Wayland" CACHE STRING "Linux Window System") if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland") add_compile_definitions(LWE_WS_WAYLAND) list(APPEND EHS_SOURCES src/IO/xdg-shell-protocol.c include/IO/xdg-shell-client-protocol.h src/IO/Window_Way.cpp include/IO/Window_Way.h) message("Building for Wayland.") elseif (LINUX_WINDOW_SYSTEM STREQUAL "XCB") add_compile_definitions(LWE_WS_XCB) list(APPEND EHS_SOURCES src/IO/Window_XCB.cpp include/IO/Window_XCB.h) message("Building for XCB.") endif () if (IS_ARCH_AMD64) list(APPEND EHS_SOURCES src/System/CPU_GCC_AMD64.asm src/HRNG_GCC.asm src/Math_GCC_AMD64.asm) elseif (IS_ARCH_ARM64) list(APPEND EHS_SOURCES src/System/CPU_ARM64.cpp src/HRNG_ARM64.cpp src/Math_GCC_ARM64.s) endif () endif() #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") #message("${CMAKE_CXX_FLAGS}") add_library(EHS ${EHS_SOURCES}) target_include_directories(EHS PUBLIC ${PROJECT_SOURCE_DIR}/include) add_executable(StrToHash src/StrToHash.cpp) set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/Libraries/EHS") install(TARGETS EHS DESTINATION lib) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include) install(TARGETS StrToHash DESTINATION bin) if (IS_ARCH_AMD64) target_include_directories(EHS PUBLIC "${PROJECT_SOURCE_DIR}/../Libraries/include") target_include_directories(EHS PUBLIC "${PROJECT_SOURCE_DIR}/../Libraries/include/zlib") target_link_directories(StrToHash PUBLIC "${PROJECT_SOURCE_DIR}/../Libraries/x64") find_package(ZLIB REQUIRED) if (ZLIB_FOUND) message(STATUS "ZLIB was found.") else () message(STATUS "ZLIB was not found.") endif () find_package(OpenSSL REQUIRED) if (OpenSSL_FOUND) message(STATUS "OpenSSL was found.") else () message(STATUS "OpenSSL was not found.") endif () target_link_libraries(EHS OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB) if (IS_OS_WINDOWS) target_link_libraries(StrToHash ws2_32 avrt LWE) elseif (IS_OS_LINUX) #add_compile_definitions(LWE_WOOTING) target_link_libraries(StrToHash z xcb xcb-cursor xcb-xfixes xcb-xinput wayland-client z asound EHS) endif () elseif (IS_ARCH_ARM64) target_include_directories(LWE PRIVATE "~/vulkan/1.3.261.1/aarch64/include") endif ()