diff --git a/.gitignore b/.gitignore index 75af8f0..d4b250e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,8 @@ CMakeCache.txt CMakeFiles/ cmake_install.cmake +compile_commands.json +Makefile + +# Final binary +stj diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..f5703c7 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.0) + +set(CMAKE_C_COMPILER "clang") +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +project(stj VERSION 0.1) + +file(GLOB st_SRC "st/*.c" "st/*.h") +file(GLOB main_SRC "*.c" "*.h") + +add_executable(stj x.c "${st_SRC}" "${main_SRC}") + +# Find required packages +# Store Find*.cmake files in ./cmake +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/") + +find_package(Freetype 2 REQUIRED) +target_include_directories(stj PRIVATE "${FREETYPE_INCLUDE_DIRS}") +target_link_libraries(stj PRIVATE "${FREETYPE_LIBRARIES}") + +find_package(Fontconfig REQUIRED) +target_include_directories(stj PRIVATE "${Fontconfig_INCLUDE_DIRS}") +target_link_libraries(stj PRIVATE "${Fontconfig_LIBRARIES}") + +find_package(X11 REQUIRED) +target_include_directories(stj PRIVATE "${X11_INCLUDE_DIR}") +target_link_libraries(stj PRIVATE "${X11_LIBRARIES}") + +# Needed to work; copied from original Makefile +target_link_libraries(stj PRIVATE m) +target_link_libraries(stj PRIVATE rt) +target_link_libraries(stj PRIVATE util) +target_link_libraries(stj PRIVATE Xft) +target_link_libraries(stj PRIVATE Xrender) + +# Add version as flag +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVERSION=\"${CMAKE_PROJECT_VERSION}\"") diff --git a/src/st/CMakeLists.txt b/src/st/CMakeLists.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/st/st.c b/src/st/st.c index abbbe4b..5758702 100644 --- a/src/st/st.c +++ b/src/st/st.c @@ -18,7 +18,7 @@ #include #include "st.h" -#include "win.h" +#include "../win.h" #if defined(__linux) #include diff --git a/src/x.c b/src/x.c index 120e495..f973a1d 100644 --- a/src/x.c +++ b/src/x.c @@ -17,7 +17,7 @@ char *argv0; #include "arg.h" -#include "st.h" +#include "st/st.h" #include "win.h" /* types used in config.h */ @@ -2036,7 +2036,7 @@ main(int argc, char *argv[]) opt_embed = EARGF(usage()); break; case 'v': - die("%s " VERSION "\n", argv0); + die("%s %s \n", argv0, VERSION); break; default: usage();