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/EHS.h src/Type.cpp include/ehs/Type.h src/BaseObj.cpp include/ehs/BaseObj.h src/GarbageCollector.cpp include/ehs/GarbageCollector.h src/Log.cpp include/ehs/Log.h src/URI.cpp include/ehs/URI.h src/Math.cpp include/ehs/Math.h src/Color4.cpp include/ehs/Color4.h src/Color3.cpp include/ehs/Color3.h src/Version.cpp include/ehs/Version.h src/Base64.cpp include/ehs/Base64.h src/Data.cpp include/ehs/Data.h src/Range.cpp include/ehs/Range.h src/Util.cpp include/ehs/Util.h src/Task.cpp include/ehs/Task.h src/DataType.cpp include/ehs/DataType.h src/Encryption.cpp include/ehs/Encryption.h include/ehs/Anchor.h include/ehs/Dock.h include/ehs/HashMap.h include/ehs/HRNG.h include/ehs/Link.h include/ehs/LinkedList.h include/ehs/Mat2.h include/ehs/Mat3.h include/ehs/Mat4.h include/ehs/PRNG.h include/ehs/Quat.h include/ehs/Rect.h include/ehs/Str.h include/ehs/Types.h include/ehs/UTF.h include/ehs/Vec2.h include/ehs/Vec3.h include/ehs/Vec4.h include/ehs/Serializer.h include/ehs/Array.h include/ehs/Vector.h include/ehs/SArray.h src/PtrData.cpp include/ehs/PtrData.h include/ehs/UniPtr.h include/ehs/ShdPtr.h include/ehs/WkPtr.h src/database/DVar.cpp include/ehs/database/DVar.h src/system/CPU.cpp include/ehs/system/CPU.h src/system/Thread.cpp include/ehs/system/Thread.h src/system/BaseMutex.cpp include/ehs/system/BaseMutex.h src/system/BaseSemaphore.cpp include/ehs/system/BaseSemaphore.h src/system/BaseSystem.cpp include/ehs/system/BaseSystem.h src/system/BaseOpen.cpp include/ehs/system/BaseOpen.h include/ehs/system/Architecture.h include/ehs/system/Mutex.h include/ehs/system/Open.h include/ehs/system/OS.h include/ehs/system/Semaphore.h include/ehs/system/System.h src/json/Json.cpp include/ehs/json/Json.h src/json/JsonBase.cpp include/ehs/json/JsonBase.h src/json/JsonNum.cpp include/ehs/json/JsonNum.h src/json/JsonBool.cpp include/ehs/json/JsonBool.h src/json/JsonStr.cpp include/ehs/json/JsonStr.h src/json/JsonObj.cpp include/ehs/json/JsonObj.h src/json/JsonArray.cpp include/ehs/json/JsonArray.h src/json/JsonVar.cpp include/ehs/json/JsonVar.h src/io/Resource.cpp include/ehs/io/Resource.h src/io/Console.cpp include/ehs/io/Console.h src/io/RIFF_Chunk.cpp include/ehs/io/RIFF_Chunk.h src/io/RIFF.cpp include/ehs/io/RIFF.h src/io/BaseWindow.cpp include/ehs/io/BaseWindow.h src/io/BaseFile.cpp include/ehs/io/BaseFile.h src/io/Glyph.cpp include/ehs/io/Glyph.h src/io/FontAtlas.cpp include/ehs/io/FontAtlas.h src/io/BaseFileMonitor.cpp include/ehs/io/BaseFileMonitor.h include/ehs/io/COM.h include/ehs/io/File.h include/ehs/io/FileMonitor.h include/ehs/io/Window.h include/ehs/io/socket/Utils.h src/io/socket/Request.cpp include/ehs/io/socket/Request.h src/io/socket/Response.cpp include/ehs/io/socket/Response.h src/io/socket/DNS.cpp include/ehs/io/socket/DNS.h src/io/socket/BaseUDP.cpp include/ehs/io/socket/BaseUDP.h src/io/socket/BaseTCP.cpp include/ehs/io/socket/BaseTCP.h src/io/socket/Comms.cpp include/ehs/io/socket/Comms.h src/io/socket/CommsSystem.cpp include/ehs/io/socket/CommsSystem.h src/io/socket/Operation.cpp include/ehs/io/socket/Operation.h src/io/socket/Fragments.cpp include/ehs/io/socket/Fragments.h src/io/socket/Endpoint.cpp include/ehs/io/socket/Endpoint.h src/io/socket/SSL.cpp include/ehs/io/socket/SSL.h src/io/socket/rest/Twitch.cpp include/ehs/io/socket/rest/Twitch.h src/io/socket/rest/TwitchChat.cpp include/ehs/io/socket/rest/TwitchChat.h src/io/socket/rest/Spotify.cpp include/ehs/io/socket/rest/Spotify.h include/ehs/io/socket/Socket.h include/ehs/io/socket/TCP.h include/ehs/io/socket/UDP.h include/ehs/io/socket/Utils.h src/io/audio/Audio.cpp include/ehs/io/audio/Audio.h src/io/audio/BaseAudioDevice.cpp include/ehs/io/audio/BaseAudioDevice.h src/io/audio/AudioCodec.cpp include/ehs/io/audio/AudioCodec.h include/ehs/io/audio/AudioDevice.h src/io/img/PNG.cpp include/ehs/io/img/PNG.h src/io/img/Img.cpp include/ehs/io/img/Img.h src/io/img/PNG_Chunk.cpp include/ehs/io/img/PNG_Chunk.h src/io/img/ImgCodec.cpp include/ehs/io/img/ImgCodec.h include/ehs/io/model/Vertex.h src/io/model/Mesh.cpp include/ehs/io/model/Mesh.h src/io/model/Bone.cpp include/ehs/io/model/Bone.h src/io/model/Model.cpp include/ehs/io/model/Model.h src/io/model/Animation.cpp include/ehs/io/model/Animation.h src/io/model/AnimBone.cpp include/ehs/io/model/AnimBone.h src/io/model/KeyFrame.cpp include/ehs/io/model/KeyFrame.h src/io/model/PropertyChange.cpp include/ehs/io/model/PropertyChange.h src/io/hid/ButtonState.cpp include/ehs/io/hid/ButtonState.h src/io/hid/Button.cpp include/ehs/io/hid/Button.h src/io/hid/Mouse.cpp include/ehs/io/hid/Mouse.h src/io/hid/Keyboard.cpp include/ehs/io/hid/Keyboard.h src/io/hid/HID.cpp include/ehs/io/hid/HID.h src/io/hid/InputHandler.cpp include/ehs/io/hid/InputHandler.h src/io/hid/Input.cpp include/ehs/io/hid/Input.h ) if (IS_OS_WINDOWS) list(APPEND EHS_SOURCES src/io/socket/UDP_W32.cpp include/ehs/io/socket/UDP_W32.h src/io/socket/TCP_W32.cpp include/ehs/io/socket/TCP_W32.h src/system/Semaphore_W32.cpp include/ehs/system/Semaphore_W32.h src/system/System_W32.cpp include/ehs/system/System_W32.h src/system/Mutex_W32.cpp include/ehs/system/Mutex_W32.h src/system/Open_W32.cpp include/ehs/system/Open_W32.h src/io/audio/audioDevice_W32.cpp include/ehs/io/audio/audioDevice_W32.h src/io/MsgBox.cpp include/ehs/io/MsgBox.h src/io/File_W32.cpp include/ehs/io/File_W32.h src/io/FileMonitor_W32.cpp include/ehs/io/FileMonitor_W32.h src/io/Window_W32.cpp include/ehs/io/Window_W32.h src/io/COM.cpp include/ehs/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/ehs/io/socket/UDP_BSD.h src/io/socket/TCP_BSD.cpp include/ehs/io/socket/TCP_BSD.h src/system/Semaphore_P.cpp include/ehs/system/Semaphore_P.h src/system/System_LNX.cpp include/ehs/system/System_LNX.h src/system/Open_UNX.cpp include/ehs/system/Open_UNX.h src/io/File_UNX.cpp include/ehs/io/File_UNX.h src/io/FileMonitor_UNX.cpp include/ehs/io/FileMonitor_UNX.h src/system/Mutex_PT.cpp include/ehs/system/Mutex_PT.h src/io/audio/AudioDevice_ALSA.cpp include/ehs/io/audio/AudioDevice_ALSA.h src/system/FileSystem.cpp include/ehs/system/FileSystem.h src/system/User.cpp include/ehs/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/ehs/io/xdg-shell-client-protocol.h src/io/Window_Way.cpp include/ehs/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/ehs/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}) add_executable(StrToHash src/StrToHash.cpp) target_include_directories(EHS PUBLIC ${PROJECT_SOURCE_DIR}/include) target_include_directories(StrToHash PUBLIC ${PROJECT_SOURCE_DIR}/include) 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) 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 EHS) elseif (IS_OS_LINUX) target_link_directories(StrToHash PRIVATE ${PROJECT_SOURCE_DIR}) target_link_libraries(StrToHash z xcb xcb-cursor xcb-xfixes xcb-xinput wayland-client z asound EHS) endif () endif ()