diff --git a/.gitignore b/.gitignore index e196d7a..a5b8de5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.o bin32/* bin64/* -.settings/* \ No newline at end of file +.settings/* +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7fefaeb --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,37 @@ +# This builds a 32-bit version of library, building 64 bit is not supported yet. + +cmake_minimum_required(VERSION 3.0) + +project(xoverlay LANGUAGES C VERSION 0.0.1) + +set(export_dest "lib/${PROJECT_NAME}-${PROJECT_VERSION}") +set(include_dest "include/${PROJECT_NAME}-${PROJECT_VERSION}") +set(lib_dest "${export_dest}/${CMAKE_BUILD_TYPE}") + +find_package(X11 REQUIRED) +find_package(GLEW REQUIRED) +find_package(OpenGL REQUIRED) + +if(NOT (X11_Xext_FOUND AND X11_Xfixes_FOUND)) + message(FATAL_ERROR "Please install Xext and Xfixes") +endif() + +add_library(${PROJECT_NAME} SHARED "") + +set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") + +target_include_directories(${PROJECT_NAME} PRIVATE + $ + $ + $ +) + +target_link_libraries(${PROJECT_NAME} ${GLEW_LIBRARIES} m rt pthread ${X11_X11_LIB} ${X11_Xext_LIB} ${X11_Xfixes_LIB}) + +add_subdirectory(include) +add_subdirectory(src) + +install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} DESTINATION "${lib_dest}") +install(FILES "include/xoverlay.h" DESTINATION "${include_dest}") +install(EXPORT ${PROJECT_NAME} DESTINATION "${lib_dest}") +install(FILES ${PROJECT_NAME}-config.cmake DESTINATION ${export_dest}) \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 41d9242..0000000 --- a/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -CC=$(shell sh -c "which gcc-7 || which gcc") -CFLAGS=-O3 -Wall -fPIC -fmessage-length=0 -D_GNU_SOURCE=1 -g3 -ggdb -Iinclude -LDFLAGS=-shared -Wl,--no-undefined -LDLIBS=-lm -lX11 -lXext -lrt -lpthread -lXfixes -lGL -lGLEW -SRC_DIR=src -BIN32_DIR=bin32 -BIN64_DIR=bin64 -SOURCES=$(shell find $(SRC_DIR) -name "*.c" -print) -OBJECTS=$(SOURCES:.c=.o) - -TARGET32=$(BIN32_DIR)/libxoverlay.so -TARGET64=$(BIN64_DIR)/libxoverlay.so -TARGET=undefined - -.PHONY: clean clean_objects - -ifeq ($(ARCH),32) -CFLAGS+=-m32 -LDFLAGS+=-m32 -TARGET=$(TARGET32) -endif -ifeq ($(ARCH),64) -TARGET=$(TARGET64) -endif - -all: - mkdir -p $(BIN32_DIR) - mkdir -p $(BIN64_DIR) -ifndef ARCH - $(MAKE) clean_objects - $(MAKE) -e ARCH=32 - $(MAKE) clean_objects - $(MAKE) -e ARCH=64 -else - $(MAKE) clean_objects - $(MAKE) $(TARGET) -endif - -install: - cp $(TARGET32) /lib/i386-linux-gnu - cp $(TARGET64) /lib/x86_64-linux-gnu - cp -R include/. /usr/local/include/xoverlay - -.c.o: - $(CC) $(CFLAGS) -c $< -o $@ - -$(TARGET): $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@ - -clean_objects: - find . -type f -name '*.o' -delete - -clean: - find . -type f -name '*.d' -delete - rm -f bin32/*.so - rm -f bin64/*.so diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..a4abbe6 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(xoverlay PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/xoverlay.h") + +add_subdirectory(internal) \ No newline at end of file diff --git a/include/internal/CMakeLists.txt b/include/internal/CMakeLists.txt new file mode 100644 index 0000000..b348921 --- /dev/null +++ b/include/internal/CMakeLists.txt @@ -0,0 +1,2 @@ +target_sources(xoverlay PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/drawglx.h") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..f158dce --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(xoverlay PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/drawglx.c" + "${CMAKE_CURRENT_LIST_DIR}/xoverlay.c") \ No newline at end of file diff --git a/xoverlay-config.cmake b/xoverlay-config.cmake new file mode 100644 index 0000000..692b59d --- /dev/null +++ b/xoverlay-config.cmake @@ -0,0 +1,2 @@ +get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${SELF_DIR}/${CMAKE_BUILD_TYPE}/xoverlay.cmake) \ No newline at end of file