Update CMakeLists.txt
This commit is contained in:
parent
432e3c4c71
commit
79d9eec0b8
|
@ -1,20 +1,11 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
|
||||
project(logmeow CXX)
|
||||
|
||||
# TODO don't hardcode compilers and linker
|
||||
set(CMAKE_C_COMPILER "clang")
|
||||
set(CMAKE_CXX_COMPILER "clang++")
|
||||
|
||||
set(LINUX_GL_LIBS -lGL)
|
||||
## ---------------------------------------------------------------------
|
||||
## OPENGL ES
|
||||
## ---------------------------------------------------------------------
|
||||
|
||||
## This assumes a GL ES library available in the system, e.g. libGLESv2.so
|
||||
# set(FLAGS "${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)
|
||||
add_link_options(-fuse-ld=lld)
|
||||
|
||||
## ---------------------------------------------------------------------
|
||||
## GENERIC BUILD FLAGS
|
||||
|
@ -23,30 +14,50 @@ set(LINUX_GL_LIBS -lGL)
|
|||
find_package(SDL2 REQUIRED)
|
||||
find_package(Freetype 2 REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
set(LIBS -lpcre2-8 -lpcre2-posix SDL2 nlohmann_json::nlohmann_json imgui)
|
||||
set(IMGUI_LIBS SDL2 Freetype::Freetype)
|
||||
list(APPEND LIBS -lpcre2-8 -lpcre2-posix SDL2 nlohmann_json::nlohmann_json imgui)
|
||||
list(APPEND IMGUI_LIBS SDL2 Freetype::Freetype)
|
||||
|
||||
set(INCLUDES imgui imgui/backends imgui/misc/cpp imgui/freetype /usr/include/SDL2)
|
||||
set(SOURCES main.cpp event_loop.cpp logcat_thread.cpp logcat_entry.cpp log.cpp config.cpp filters.cpp misc.cpp pcre2_wrapper.cpp
|
||||
set(INCLUDES "")
|
||||
set(SOURCES "")
|
||||
set(IMGUI_SOURCES "")
|
||||
set(DEFINITIONS "")
|
||||
list(APPEND INCLUDES imgui imgui/backends imgui/misc/cpp imgui/freetype /usr/include/SDL2)
|
||||
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
|
||||
group_panel.cpp fragments/filters.cpp windows/logs.cpp windows/settings.cpp windows/filters.cpp windows/exclusions.cpp windows/main.cpp)
|
||||
set(IMGUI_SOURCES imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_widgets.cpp imgui/imgui_tables.cpp
|
||||
list(APPEND IMGUI_SOURCES imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_widgets.cpp imgui/imgui_tables.cpp
|
||||
imgui/misc/cpp/imgui_stdlib.cpp imgui/misc/freetype/imgui_freetype.cpp
|
||||
imgui/backends/imgui_impl_sdl.cpp imgui/backends/imgui_impl_opengl3.cpp)
|
||||
list(APPEND DEFINITIONS -DIMGUI_USER_CONFIG="../myimconfig.h")
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(SOURCES ${SOURCES} windows/debug.cpp)
|
||||
set(IMGUI_SOURCES ${IMGUI_SOURCES} imgui/imgui_demo.cpp)
|
||||
if ("${FLAGS}" STREQUAL "")
|
||||
set(FLAGS "-fsanitize=undefined,thread")
|
||||
if (CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
list(APPEND SOURCES windows/debug.cpp)
|
||||
list(APPEND IMGUI_SOURCES imgui/imgui_demo.cpp)
|
||||
if (NOT FLAGS)
|
||||
list(APPEND FLAGS -fsanitize=undefined,thread)
|
||||
endif()
|
||||
# https://sourceforge.net/p/valgrind/mailman/valgrind-users/thread/Ygze8PzaQAYWlKDj%40wildebeest.org/
|
||||
list(APPEND FLAGS -gdwarf-4)
|
||||
endif()
|
||||
|
||||
set(FLAGS "${FLAGS} -DIMGUI_USER_CONFIG='\"../myimconfig.h\"'")
|
||||
# https://t.me/NightShadowsHangout/670691
|
||||
# https://t.me/NightShadowsHangout/688372
|
||||
set(FLAGS "${FLAGS} -Werror -Wall -Wextra -Wshadow -Wpedantic -Wno-gnu-anonymous-struct -fPIC -Wconversion -Wno-unused-parameter -Wimplicit-fallthrough")
|
||||
# https://sourceforge.net/p/valgrind/mailman/valgrind-users/thread/Ygze8PzaQAYWlKDj%40wildebeest.org/
|
||||
set(FLAGS "${FLAGS} -gdwarf-4")
|
||||
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)
|
||||
|
||||
## ---------------------------------------------------------------------
|
||||
## BUILD FLAGS PER PLATFORM
|
||||
|
@ -54,31 +65,39 @@ set(FLAGS "${FLAGS} -gdwarf-4")
|
|||
|
||||
if (LINUX)
|
||||
find_package(Fontconfig)
|
||||
set(LIBS ${LIBS} ${LINUX_GL_LIBS} -ldl)
|
||||
set(IMGUI_LIBS ${IMGUI_LIBS} ${LINUX_GL_LIBS} -ldl)
|
||||
list(APPEND LIBS ${LINUX_GL_LIBS} -ldl)
|
||||
list(APPEND IMGUI_LIBS ${LINUX_GL_LIBS} -ldl)
|
||||
if (Fontconfig_FOUND)
|
||||
set(FLAGS "${FLAGS} -DUSE_FONTCONFIG")
|
||||
set(LIBS ${LIBS} Fontconfig::Fontconfig)
|
||||
set(SOURCES ${SOURCES} fonts.cpp)
|
||||
list(APPEND FLAGS -DUSE_FONTCONFIG)
|
||||
list(APPEND LIBS Fontconfig::Fontconfig)
|
||||
list(APPEND SOURCES fonts.cpp)
|
||||
endif()
|
||||
elseif (APPLE)
|
||||
set(LIBS ${LIBS} -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -L/usr/local/lib -L/opt/local/lib)
|
||||
set(INCLUDES ${INCLUDES} /usr/local/include /opt/local/include)
|
||||
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)
|
||||
elseif (WIN32)
|
||||
set(LIBS ${LIBS} -lgdi32 -lopengl32 -limm32)
|
||||
list(APPEND LIBS -lgdi32 -lopengl32 -limm32)
|
||||
endif()
|
||||
|
||||
add_link_options(-fuse-ld=lld)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
## ---------------------------------------------------------------------
|
||||
## PROJECT
|
||||
## ---------------------------------------------------------------------
|
||||
|
||||
add_library(imgui STATIC ${IMGUI_SOURCES})
|
||||
target_include_directories(imgui PRIVATE ${INCLUDES})
|
||||
target_link_libraries(imgui PRIVATE ${IMGUI_LIBS})
|
||||
target_compile_definitions(imgui PRIVATE ${DEFINITIONS})
|
||||
# dear imgui has some fucky wucky with -Wconversion, hence -Wno-conversion
|
||||
target_compile_options(imgui PRIVATE -Wno-conversion)
|
||||
target_compile_options(imgui PRIVATE ${FLAGS} -Wno-conversion)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
CXX_STANDARD_REQUIRED YES
|
||||
CXX_EXTENSIONS NO
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDES})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBS})
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFINITIONS})
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS})
|
||||
|
|
Loading…
Reference in New Issue