2023-01-22 14:28:14 +00:00
|
|
|
cmake_minimum_required(VERSION 3.25)
|
|
|
|
|
2023-02-15 14:09:57 +00:00
|
|
|
project(logmeow CXX)
|
|
|
|
|
2023-01-22 14:28:14 +00:00
|
|
|
## ---------------------------------------------------------------------
|
|
|
|
## GENERIC BUILD FLAGS
|
|
|
|
## ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
find_package(Freetype 2 REQUIRED)
|
2023-01-31 14:40:04 +00:00
|
|
|
find_package(nlohmann_json REQUIRED)
|
2023-03-28 17:03:16 +00:00
|
|
|
list(APPEND LIBS -lpcre2-8 -lpcre2-posix SDL2 nlohmann_json::nlohmann_json imgui nfd)
|
2023-02-14 14:21:02 +00:00
|
|
|
list(APPEND IMGUI_LIBS SDL2 Freetype::Freetype)
|
2023-01-22 14:28:14 +00:00
|
|
|
|
2023-02-14 14:21:02 +00:00
|
|
|
set(INCLUDES "")
|
|
|
|
set(SOURCES "")
|
|
|
|
set(IMGUI_SOURCES "")
|
|
|
|
set(DEFINITIONS "")
|
2023-03-28 16:48:26 +00:00
|
|
|
# imgui include because https://github.com/ocornut/imgui/issues/6184#issuecomment-1439570929
|
2023-02-22 09:09:33 +00:00
|
|
|
list(APPEND INCLUDES thirdparty thirdparty/imgui /usr/include/SDL2)
|
2023-02-14 14:21:02 +00:00
|
|
|
list(APPEND SOURCES main.cpp event_loop.cpp logcat_thread.cpp logcat_entry.cpp log.cpp config.cpp filters.cpp misc.cpp pcre2_wrapper.cpp
|
2023-03-28 17:03:16 +00:00
|
|
|
group_panel.cpp fragments/filters.cpp fragments/export.cpp windows/logs.cpp windows/settings.cpp windows/main.cpp)
|
2023-02-22 09:09:33 +00:00
|
|
|
list(APPEND IMGUI_SOURCES thirdparty/imgui/imgui.cpp thirdparty/imgui/imgui_draw.cpp thirdparty/imgui/imgui_widgets.cpp thirdparty/imgui/imgui_tables.cpp
|
|
|
|
thirdparty/imgui/misc/cpp/imgui_stdlib.cpp thirdparty/imgui/misc/freetype/imgui_freetype.cpp
|
|
|
|
thirdparty/imgui/backends/imgui_impl_sdl2.cpp thirdparty/imgui/backends/imgui_impl_opengl3.cpp)
|
|
|
|
list(APPEND DEFINITIONS -DIMGUI_USER_CONFIG="../../myimconfig.h")
|
2023-01-25 05:38:12 +00:00
|
|
|
|
2023-02-14 14:21:02 +00:00
|
|
|
if (CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
|
|
list(APPEND SOURCES windows/debug.cpp)
|
2023-02-22 09:09:33 +00:00
|
|
|
list(APPEND IMGUI_SOURCES thirdparty/imgui/imgui_demo.cpp)
|
2023-02-14 14:21:02 +00:00
|
|
|
if (NOT FLAGS)
|
|
|
|
list(APPEND FLAGS -fsanitize=undefined,thread)
|
2023-01-25 05:38:12 +00:00
|
|
|
endif()
|
2023-02-14 14:21:02 +00:00
|
|
|
# https://sourceforge.net/p/valgrind/mailman/valgrind-users/thread/Ygze8PzaQAYWlKDj%40wildebeest.org/
|
|
|
|
list(APPEND FLAGS -gdwarf-4)
|
2023-01-22 14:28:14 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# https://t.me/NightShadowsHangout/670691
|
2023-01-28 14:11:46 +00:00
|
|
|
# https://t.me/NightShadowsHangout/688372
|
2023-02-14 14:21:02 +00:00
|
|
|
list(APPEND FLAGS -Werror -Wall -Wextra -Wshadow -Wpedantic -Wno-gnu-anonymous-struct -fPIC -Wconversion -Wno-unused-parameter -Wimplicit-fallthrough)
|
|
|
|
|
|
|
|
# i have no idea why this hack wasn't needed before but it's needed if sanitizers are used
|
|
|
|
add_link_options(${FLAGS})
|
|
|
|
|
|
|
|
## ---------------------------------------------------------------------
|
|
|
|
## OPENGL ES
|
|
|
|
## ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
set(LINUX_GL_LIBS -lGL)
|
|
|
|
|
|
|
|
## This assumes a GL ES library available in the system, e.g. libGLESv2.so
|
|
|
|
# list(APPEND FLAGS -DIMGUI_IMPL_OPENGL_ES2)
|
|
|
|
# set(LINUX_GL_LIBS -lGLESv2)
|
|
|
|
## If you're on a Raspberry Pi and want to use the legacy drivers,
|
|
|
|
## use the following instead:
|
|
|
|
# set(LINUX_GL_LIBS -L/opt/vc/lib -lbrcmGLESv2)
|
2023-01-22 14:28:14 +00:00
|
|
|
|
|
|
|
## ---------------------------------------------------------------------
|
|
|
|
## BUILD FLAGS PER PLATFORM
|
|
|
|
## ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
if (LINUX)
|
|
|
|
find_package(Fontconfig)
|
2023-02-14 14:21:02 +00:00
|
|
|
list(APPEND LIBS ${LINUX_GL_LIBS} -ldl)
|
|
|
|
list(APPEND IMGUI_LIBS ${LINUX_GL_LIBS} -ldl)
|
2023-02-21 08:09:45 +00:00
|
|
|
list(APPEND FLAGS -DUSE_EPOLL)
|
2023-01-22 14:28:14 +00:00
|
|
|
if (Fontconfig_FOUND)
|
2023-02-14 14:21:02 +00:00
|
|
|
list(APPEND FLAGS -DUSE_FONTCONFIG)
|
|
|
|
list(APPEND LIBS Fontconfig::Fontconfig)
|
|
|
|
list(APPEND SOURCES fonts.cpp)
|
2023-01-22 14:28:14 +00:00
|
|
|
endif()
|
|
|
|
elseif (APPLE)
|
2023-02-14 14:21:02 +00:00
|
|
|
list(APPEND LIBS -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -L/usr/local/lib -L/opt/local/lib)
|
|
|
|
list(APPEND INCLUDES /usr/local/include /opt/local/include)
|
2023-01-22 14:28:14 +00:00
|
|
|
elseif (WIN32)
|
2023-02-14 14:21:02 +00:00
|
|
|
list(APPEND LIBS -lgdi32 -lopengl32 -limm32)
|
2023-01-22 14:28:14 +00:00
|
|
|
endif()
|
|
|
|
|
2023-02-14 14:21:02 +00:00
|
|
|
## ---------------------------------------------------------------------
|
|
|
|
## PROJECT
|
|
|
|
## ---------------------------------------------------------------------
|
2023-01-22 14:28:14 +00:00
|
|
|
|
|
|
|
add_library(imgui STATIC ${IMGUI_SOURCES})
|
|
|
|
target_include_directories(imgui PRIVATE ${INCLUDES})
|
|
|
|
target_link_libraries(imgui PRIVATE ${IMGUI_LIBS})
|
2023-02-14 14:21:02 +00:00
|
|
|
target_compile_definitions(imgui PRIVATE ${DEFINITIONS})
|
2023-01-22 14:28:14 +00:00
|
|
|
# dear imgui has some fucky wucky with -Wconversion, hence -Wno-conversion
|
2023-02-16 14:57:42 +00:00
|
|
|
# it seems like compilers may issue a warning for unknown warnings to ignore
|
|
|
|
target_compile_options(imgui PRIVATE ${FLAGS} -Wno-unknown-warning-option -Wno-conversion)
|
2023-01-22 14:28:14 +00:00
|
|
|
|
2023-03-28 17:03:16 +00:00
|
|
|
set(NFD_PORTAL ON)
|
|
|
|
add_subdirectory(thirdparty/nativefiledialog-extended)
|
|
|
|
|
2023-01-22 14:28:14 +00:00
|
|
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
2023-02-14 14:21:02 +00:00
|
|
|
set_target_properties(${PROJECT_NAME}
|
|
|
|
PROPERTIES
|
|
|
|
CXX_STANDARD 20
|
|
|
|
CXX_STANDARD_REQUIRED YES
|
|
|
|
CXX_EXTENSIONS NO
|
|
|
|
)
|
2023-01-22 14:28:14 +00:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDES})
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBS})
|
2023-02-14 14:21:02 +00:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFINITIONS})
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS})
|