Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Basic CMake Support, Fix Conversion Test Compilation #28

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

cullvox
Copy link

@cullvox cullvox commented Jun 24, 2024

In one of my projects I'm working on it's useful to have support for CMake. I am using CPM, and to easily add a small library like this I think it might be useful to have some CMake support. What I added is just an interface library for the header and also compiling the test cases.

Usage of the overload template helper in the conversion test, was causing a compiler error when using AppleClang.

Added a basic cmake lists script.

Fixed the overload template usage in the conversion test, was causing a compiler error when using AppleClang.

Added header include that shouldn't need to be included . The standard says that including it does nothing but on Windows MSVC when using the header as a standalone file it gave me an issue.
@wx257osn2
Copy link
Owner

wx257osn2 commented Jul 16, 2024

@cullvox

  • Please remove .gitignore , because:
    • clangd is your option, so it should be ignored with your own $XDG_CONFIG_HOME/git/ignore instead of project one
    • build is not necessarily specified as build directory by cmake
  • Please add EOL on EOF of CMakeLists.txt
  • Would you provide a simple CMakeLists.txt example here of how it would be used from CPM when this CMakeLists.txt will be added? I don't use cmake usually, so I can't imagine how it will be.

@cullvox
Copy link
Author

cullvox commented Jul 16, 2024

cmake_minimum_required(VERSION 3.14)
project(qoixx_sample LANGUAGES CXX)

include(CMake/CPM.cmake) # CPM module

CPMAddPackage("gh:wx257osn2/[email protected]")

add_executable(qoixx_sample "main.cpp")
target_link_libraries(qoixx_sample PUBLIC qoixx::qoixx)

Here's an example CMake for this.

@wx257osn2
Copy link
Owner

@cullvox Sorry to late for reply, I tried to check the behavior. It seems that it works well for CPM (without above issue), but when we build qoixx with CMake, 3 binaries (qoibench , qoiconv , and qoitest) are generated on the build directory. Currently Makefile generates binaries on bin/ directory, so we can copy it to our own $PATH , but it is hard to understand to what binaries to copy to where with current CMakeLists.txt . Would you support installing (make install) for qoiconv and qoibench ? (qoitest is not needed to support this)

@cullvox
Copy link
Author

cullvox commented Sep 24, 2024

@wx257osn2 Hi, I'm providing a late reply too. I added an install for the qoiconv and qoibench targets. I tested this on Windows and Ubuntu. Using cmake --install {build folder} will install the files to the bin folder, or you could go into the CMake build folder and call make install and it works the same way. I think this is what you were asking for — if not I'll gladly add/change anything!

add_library(qoixx INTERFACE)
add_library(qoixx::qoixx ALIAS qoixx)
target_include_directories(qoixx INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_compile_definitions(qoixx INTERFACE QOIXX_DECODE_WITH_TABLES=${QOIXX_USE_TABLES})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be -DQOIXX_DECODE_WITH_TABLES=ON , but QOIXX_DECODE_WITH_TABLES must be 0 or 1 . Please fix this

@wx257osn2
Copy link
Owner

wx257osn2 commented Sep 25, 2024

@cullvox Thank you for working it!

  • Would you make CMAKE_INSTALL_PREFIX to behave correctly?
    • After this changing, cmake --install {build folder} without CMAKE_INSTALL_PREFIX may install them into /usr/local (on Linux environment) or something like that IMO
    • Currently there is no install target in Makefile to refer (sorry), but I want CMake version similar to PREFIX=/path/to make install .
  • Yikes, I'd missed to send review comment (it was "pending" status... (◞‸◟) ). I sent it, so please fix above comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants