diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f73c092..fd0f160 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -3,6 +3,7 @@ name: Linux on: pull_request: push: + workflow_dispatch: jobs: build: @@ -16,16 +17,16 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Installation + - name: Install CMake 3.22.0 + # gflags 2.2.2 uses cmake 3.0, and the latest cmake doesn't support cmake that <= 3.5 + # To pass the tests, install the specified cmake run: | - sudo apt-get install -y cmake - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 60 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 - sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-9 60 - sudo update-alternatives --set g++ /usr/bin/g++-9 - sudo update-alternatives --set gcc /usr/bin/gcc-9 - sudo update-alternatives --set cpp /usr/bin/cpp-9 + set -e + curl -sL https://cmake.org/files/v3.22/cmake-3.22.0-linux-x86_64.tar.gz | tar -xz + echo "$(pwd)/cmake-3.22.0-linux-x86_64/bin" >> $GITHUB_PATH + cmake --version - name: Tests run: | ./scripts/test-unix.sh + diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7c3399c..2864e48 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -3,6 +3,7 @@ name: macOS on: pull_request: push: + workflow_dispatch: jobs: build: @@ -16,10 +17,16 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Installation + - name: Install CMake 3.22 + # gflags 2.2.2 uses cmake 3.0, and the latest cmake doesn't support cmake that <= 3.5 + # To pass the tests, install the specified cmake run: | - brew install cmake + set -e + curl -sL https://cmake.org/files/v3.22/cmake-3.22.0-macos-universal.tar.gz | tar -xzv + echo "$(pwd)/cmake-3.22.0-macos-universal/CMake.app/Contents/bin" >> $GITHUB_PATH + cmake --version - name: Tests run: | ./scripts/test-unix.sh + diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b4fc51d..6156258 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -3,6 +3,7 @@ name: Windows on: pull_request: push: + workflow_dispatch: jobs: build: diff --git a/README.md b/README.md index 395dc10..ac52b20 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ After calling `xrepo_package(foo)`, there are three ways to use `foo` package: 1. Call `find_package(foo)` if package provides cmake config-files. - Refer to CMake [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html) documentation for more details. 2. If the package does not provide cmake config files or find modules - - Following variables can be used to use the pacakge (variable names following cmake + - Following variables can be used to use the package (variable names following cmake find modules [standard variable names](https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names)) - `foo_INCLUDE_DIRS` - `foo_LIBRARY_DIRS` @@ -252,7 +252,7 @@ We can write a custom package in xmake.lua, please refer [Define Xrepo package]( ### Options and variables for `xrepo.cmake` -Following options can be speicified with `cmake -D=`. +Following options can be specified with `cmake -D=`. Or use `set(var value)` in `CMakeLists.txt`. - `XMAKE_CMD`: string, defaults to empty string @@ -277,7 +277,7 @@ Or use `set(var value)` in `CMakeLists.txt`. ### Switching compiler and cross compilation -Following variables controll cross compilation. Note: to specify a different compiler other than +Following variables control cross compilation. Note: to specify a different compiler other than the default one on system, platform must be set to "cross". - `XREPO_TOOLCHAIN`: string, defaults to empty string @@ -391,5 +391,5 @@ the specified package. For CMake 3.19 and later which has JSON support, `xrepo_package` parses the JSON output. For previous version of CMake, `xrepo_package` uses only the `--cflags` option -to get package include directory. Library and cmake module directory are infered from that +to get package include directory. Library and cmake module directory are inferred from that directory, so it maybe unreliable to detect the correct paths. diff --git a/example-bin b/example-bin new file mode 100755 index 0000000..832b93a Binary files /dev/null and b/example-bin differ diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index c750775..a373b37 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -26,7 +26,7 @@ xrepo_package("glog" #DEPS CONFIGS "packages/glog.lua") -# find_pacakge works because package install dir is added to CMAKE_PREFIX_PATH. +# find_package works because package install dir is added to CMAKE_PREFIX_PATH. find_package(gflags) find_package(glog) @@ -40,8 +40,8 @@ add_executable(example-bin "") target_sources(example-bin PRIVATE src/main.cpp ) -# For packges that does not provide cmake config-file packages, -# xrepo_target_packges is convenient to setup include, library path and link targets. +# For packages that does not provide cmake config-file packages, +# xrepo_target_packages is convenient to setup include, library path and link targets. # We can specify multiple packages in a single call. #xrepo_target_packages(example-bin pcre2 zlib) diff --git a/example/packages/xmake.lua b/example/packages/xmake.lua index 0a125e5..b0b3ebe 100644 --- a/example/packages/xmake.lua +++ b/example/packages/xmake.lua @@ -5,8 +5,8 @@ package("myzlib") add_urls("https://github.com/madler/zlib/archive/$(version).tar.gz", "https://github.com/madler/zlib.git") - add_versions("v1.2.10", "42cd7b2bdaf1c4570e0877e61f2fdc0bce8019492431d054d3d86925e5058dc5") - add_versions("v1.2.11", "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff") + add_versions("v1.3", "b5b06d60ce49c8ba700e0ba517fa07de80b5d4628a037f4be8ad16955be7a7c0") + add_versions("v1.3.1", "17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c") on_install(function (package) io.writefile("xmake.lua", [[ diff --git a/xrepo.cmake b/xrepo.cmake index 64945c6..4fe14f1 100644 --- a/xrepo.cmake +++ b/xrepo.cmake @@ -67,14 +67,14 @@ set(XREPO_XMAKEFILE "" CACHE STRING "Xmake script file of Xrepo package") # `target_link_directories` to use the package. # - User should figure out what library to use for `target_link_libraries`. # - If `DIRECTORY_SCOPE` is specified, execute following code so the package -# can be used in cmake's direcotry scope: +# can be used in cmake's directory scope: # include_directories(foo_INCLUDE_DIRS) # link_directories(foo_LIBRARY_DIRS) # 3. Append package install directory to `CMAKE_PREFIX_PATH`. function(_install_xmake_program) if (NOT XMAKE_RELEASE_LATEST) - set(XMAKE_RELEASE_LATEST 2.9.4) + set(XMAKE_RELEASE_LATEST 3.0.3) endif() set(XMAKE_VERSION master) set(XMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/xmake) @@ -217,8 +217,8 @@ function(_detect_toolchain) get_filename_component(_compiler_name "${CMAKE_C_COMPILER}" NAME_WLE) elseif(DEFINED CMAKE_CXX_COMPILER) get_filename_component(_compiler_name "${CMAKE_CXX_COMPILER}" NAME_WLE) - string(REPLACE "g++" "gcc" "${_compiler_name}" _compiler_name) - string(REPLACE "clang++" "clang" "${_compiler_name}" _compiler_name) + string(REPLACE "g++" "gcc" _compiler_name "${_compiler_name}") + string(REPLACE "clang++" "clang" _compiler_name "${_compiler_name}") else() # Shouldn't reach here because cmake will try to detect compiler and set # corresponding variables. @@ -375,7 +375,7 @@ function(xrepo_package package) _xrepo_finish_package_setup(${package_name}) - # Store xrepo command and arguments for furture comparison. + # Store xrepo command and arguments for future comparison. set(_cache_xrepo_cmdargs_${package_name} "${_xrepo_cmdargs_${package_name}}" CACHE INTERNAL "") endfunction() @@ -421,7 +421,7 @@ function(xrepo_target_packages target) endforeach() endfunction() -# Append parent directorie of include directory to CMAKE_PREFIX_PATH. +# Append parent directory of include directory to CMAKE_PREFIX_PATH. macro(_xrepo_set_cmake_prefix_path package_name) # CMake looks for quite a few directories under each prefix directory for config-file.cmake. # Thus Using CMAKE_PREFIX_PATH is easier and more reliable for config-file packages to be found