From 4ae7bba6384366909010b6f9c7501a35133f31ed Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 6 Jul 2022 07:03:19 -0400 Subject: [PATCH] Add CMakeLists.txt (#8) * Add CMakeLists.txt * Use CMake in CI * Remove Makefile & update README.md --- .github/workflows/ci.yml | 14 +++++++++----- .gitignore | 3 +++ CMakeLists.txt | 16 ++++++++++++++++ Dockerfile | 9 ++++++--- Makefile | 27 --------------------------- README.md | 6 ++++-- 6 files changed, 38 insertions(+), 37 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e0ee4d..c341626 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,26 +10,30 @@ jobs: - name: Install GCC multilib run: | sudo apt-get update - sudo apt-get install -y gcc-multilib g++-multilib + sudo apt-get install -y gcc-multilib g++-multilib ninja-build + + - name: Configure + # Replace with RelWithDebInfo when -O2 crash is fixed + run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug - name: Build - run: make -j + run: cmake --build build - name: Test run: | wget https://cdn.discordapp.com/attachments/727918646525165659/917185027656286218/GC_WII_COMPILERS.zip unzip GC_WII_COMPILERS.zip - MWCIncludes=. ./wibo GC/2.7/mwcceppc.exe -c test/test.c + MWCIncludes=. build/wibo GC/2.7/mwcceppc.exe -c test/test.c file test.o - name: Upload build uses: actions/upload-artifact@v2 with: name: wibo - path: wibo + path: build/wibo - name: Publish release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: - files: wibo + files: build/wibo diff --git a/.gitignore b/.gitignore index db166ac..f7d5541 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ build/ *.o .vscode/ +# CLion +.idea/ +cmake-build-*/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..143db54 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.13) +project(wibo LANGUAGES CXX) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -Wall") +add_executable(wibo + advapi32.cpp + files.cpp + kernel32.cpp + lmgr.cpp + loader.cpp + main.cpp + ole32.cpp + user32.cpp + version.cpp + ) +install(PROGRAMS wibo DESTINATION bin) diff --git a/Dockerfile b/Dockerfile index ecbe4e0..8187973 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,14 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends \ g++ \ g++-multilib \ - make + cmake \ + ninja-build COPY . /wibo -RUN make -C /wibo +# Replace with RelWithDebInfo when -O2 crash is fixed +RUN cmake -S /wibo -B /wibo/build -G Ninja -DCMAKE_BUILD_TYPE=Debug +RUN cmake --build /wibo/build FROM ubuntu:22.04 @@ -18,6 +21,6 @@ RUN dpkg --add-architecture i386 \ && apt-get install -y --no-install-recommends \ libstdc++6:i386 -COPY --from=build /wibo/wibo /usr/local/sbin/wibo +COPY --from=build /wibo/build/wibo /usr/local/sbin/wibo CMD /usr/local/sbin/wibo diff --git a/Makefile b/Makefile deleted file mode 100644 index af89e27..0000000 --- a/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -all: wibo - -CXXFLAGS = -Wall -g -m32 -std=c++17 -lstdc++ -MD -LDFLAGS = -lstdc++fs - -BUILD_DIR := build -CPP_FILES := $(wildcard *.cpp) -O_FILES := $(foreach file,$(CPP_FILES),$(BUILD_DIR)/$(file:.cpp=.o)) -DEP_FILES := $(O_FILES:.o=.d) - -$(BUILD_DIR): - mkdir -p $(BUILD_DIR) - -$(BUILD_DIR)/%.o: %.cpp | $(BUILD_DIR) - $(CXX) -c $(CXXFLAGS) $< -o $@ - -wibo: $(O_FILES) - $(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS) - -clean: - $(RM) -r $(BUILD_DIR) wibo - -.PHONY: all clean - -MAKEFLAGS += --no-builtin-rules - --include $(DEP_FILES) diff --git a/README.md b/README.md index c4b38a1..f15c49d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ A minimal, low-fuss wrapper that can run really simple command-line 32-bit Windo Don't run this on any untrusted executables, I implore you. (Or probably just don't run it at all... :p) - make && ./wibo + cmake -B build + cmake --build build + build/wibo --- @@ -19,4 +21,4 @@ Rough to-do list: --- Related projects: -* [taviso/loadlibrary](https://github.com/taviso/loadlibrary) \ No newline at end of file +* [taviso/loadlibrary](https://github.com/taviso/loadlibrary)