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/rest/Twitch.cpp include/io/socket/rest/Twitch.h src/io/socket/rest/TwitchChat.cpp include/io/socket/rest/TwitchChat.h src/io/socket/rest/Spotify.cpp include/io/socket/rest/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(EHS_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(EHS_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/ehs) 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(EHS_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 ()