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 shared library target to CMake #60

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -97,8 +100,6 @@ add_link_options(
)
endif()

set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON")


# QuickJS library
#
Expand All @@ -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
Expand Down