Skip to content

Commit

Permalink
chore: update cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Jul 8, 2024
1 parent 4c83e10 commit 4e409b9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/cortex-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,27 @@ jobs:
runs-on: "ubuntu-20-04"
cmake-flags: ""
build-deps-cmake-flags: ""
ccache-dir: ""
arch: "x64"
platform: "linux"
- os: "mac"
name: "amd64"
runs-on: "macos-13"
cmake-flags: ""
build-deps-cmake-flags: ""
ccache-dir: ""
arch: "x64"
platform: "darwin"
- os: "mac"
name: "arm64"
runs-on: "macos-latest"
cmake-flags: "-DMAC_ARM64=ON"
build-deps-cmake-flags: ""
ccache-dir: ""
arch: "arm64"
platform: "darwin"
- os: "windows"
name: "amd64"
runs-on: "windows-cuda-12-0"
cmake-flags: "-DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -GNinja"
build-deps-cmake-flags: "-DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -GNinja"
ccache-dir: 'C:\Users\ContainerAdministrator\AppData\Local\ccache'
arch: "x64"
platform: "windows"

Expand Down Expand Up @@ -184,7 +180,6 @@ jobs:

- name: "Update version by tag"
working-directory: cortex-cpp
shell: bash
run: |
echo "Version: ${{ needs.create-draft-release.outputs.version }}"
# Update the version in package.json
Expand Down Expand Up @@ -212,6 +207,7 @@ jobs:

# Setup .npmrc file to publish to npm - upload only once
- run: npm publish --access public
continue-on-error: true
if: runner.os == 'linux'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
38 changes: 17 additions & 21 deletions cortex-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0042 NEW)
project(cortex-cpp C CXX)

# Build using CMAKE-JS
if(DEFINED CMAKE_JS_INC)
include_directories(${CMAKE_JS_INC})
endif()
project(cortex-cpp C CXX)

# Build using CMAKE-JS
if(DEFINED CMAKE_JS_INC)
Expand Down Expand Up @@ -97,9 +91,23 @@ endif()
# and comment out the following lines

find_package(Drogon CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon
${CMAKE_THREAD_LIBS_INIT})


# Build using CMAKE-JS
if(DEFINED CMAKE_JS_INC)
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")

target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_JS_LIB})

if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
# Generate node.lib
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
endif()
else()
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon
${CMAKE_THREAD_LIBS_INIT})
endif()
# ##############################################################################

if(CMAKE_CXX_STANDARD LESS 17)
Expand Down Expand Up @@ -132,15 +140,3 @@ target_sources(${PROJECT_NAME} PRIVATE ${CTL_SRC} ${COMMON_SRC})
# ##############################################################################
# uncomment the following line for dynamically loading views set_property(TARGET
# ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS ON)

# Build using CMAKE-JS
if(DEFINED CMAKE_JS_INC)
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")

target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})

if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
# Generate node.lib
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
endif()
endif()
12 changes: 6 additions & 6 deletions cortex-cpp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"url": "git+https://github.com/janhq/cortex.git"
},
"scripts": {
"install": "prebuild-install --runtime napi --backend cmake-js || cmake-js rebuild",
"build": "cmake-js configure && cmake-js build",
"rebuild": "cmake-js rebuild",
"prebuild": "prebuild --runtime napi --backend cmake-js --all --strip --verbose",
"install": "prebuild-install --runtime napi --backend cmake-js --config Release || cmake-js rebuild --config Release",
"build": "cmake-js configure --config Release && cmake-js build --config Release",
"rebuild": "cmake-js rebuild --config Release",
"prebuild": "prebuild --runtime napi --backend cmake-js --all --strip --verbose --config Release",
"upload": "prebuild --runtime napi --backend cmake-js --upload ${GITHUB_TOKEN}"
},
"author": "Jan <[email protected]>",
Expand All @@ -35,7 +35,7 @@
]
},
"files": [
"*.js",
"*.d.ts"
"binding/*.js",
"binding/*.d.ts"
]
}

0 comments on commit 4e409b9

Please sign in to comment.