Add shared library target to CMake (#60)
This commit is contained in:
parent
cc3e062484
commit
0b09109151
2 changed files with 64 additions and 5 deletions
58
.github/workflows/ci.yml
vendored
58
.github/workflows/ci.yml
vendored
|
@ -48,6 +48,21 @@ jobs:
|
|||
if: ${{ matrix.buildType == 'Release' }}
|
||||
run: |
|
||||
time ./build/run-test262 -m -c test262.conf -a
|
||||
linux-shared:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_SHARED_LIBS=ON ..
|
||||
cd ..
|
||||
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||
ldd build/qjs
|
||||
- name: stats
|
||||
run: |
|
||||
./build/qjs -qd
|
||||
linux-asan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -160,6 +175,21 @@ jobs:
|
|||
./build/qjs tests/test_loop.js
|
||||
./build/qjs tests/test_std.js
|
||||
./build/qjs tests/test_worker.js
|
||||
macos-shared:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_SHARED_LIBS=ON ..
|
||||
cd ..
|
||||
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||
otool -L build/qjs
|
||||
- name: stats
|
||||
run: |
|
||||
./build/qjs -qd
|
||||
macos-asan:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
|
@ -248,3 +278,31 @@ jobs:
|
|||
./build/qjs tests/test_builtin.js
|
||||
./build/qjs tests/test_loop.js
|
||||
./build/qjs tests/test_std.js
|
||||
windows-mingw-shared:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
install: >-
|
||||
git
|
||||
make
|
||||
pacboy: >-
|
||||
cmake:p
|
||||
ninja:p
|
||||
toolchain:p
|
||||
- name: build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_SHARED_LIBS=ON ..
|
||||
cd ..
|
||||
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||
ldd build/qjs
|
||||
- name: stats
|
||||
run: |
|
||||
./build/qjs -qd
|
||||
|
|
|
@ -3,10 +3,8 @@ cmake_minimum_required(VERSION 3.9)
|
|||
project(quickjs LANGUAGES C)
|
||||
|
||||
# TODO:
|
||||
# - LTO
|
||||
# - Support cross-compilation
|
||||
# - Install targets
|
||||
# - Shared library target
|
||||
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_EXTENSIONS ON)
|
||||
|
@ -52,6 +50,11 @@ else()
|
|||
add_compile_options(-g)
|
||||
endif()
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build a shared library" OFF)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
message(STATUS "Building a shared library")
|
||||
endif()
|
||||
|
||||
option(CONFIG_ASAN "Enable AddressSanitizer (ASan)" OFF)
|
||||
option(CONFIG_MSAN "Enable MemorySanitizer (MSan)" OFF)
|
||||
option(CONFIG_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)
|
||||
|
@ -97,8 +100,6 @@ add_link_options(
|
|||
)
|
||||
endif()
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON")
|
||||
|
||||
|
||||
# QuickJS library
|
||||
#
|
||||
|
@ -113,7 +114,7 @@ set(qjs_sources
|
|||
|
||||
list(APPEND qjs_defines _GNU_SOURCE)
|
||||
|
||||
add_library(qjs STATIC ${qjs_sources})
|
||||
add_library(qjs ${qjs_sources})
|
||||
target_compile_definitions(qjs PRIVATE ${qjs_defines})
|
||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
target_compile_definitions(qjs PRIVATE
|
||||
|
|
Loading…
Reference in a new issue