diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-05-26 11:37:17 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-07-11 15:49:14 +0200 |
commit | e2b3d2ef25c5e55122c1e41ab56af1075209b47d (patch) | |
tree | 71b5ef51d04169b19b2a98ebf64b82302bb2437b | |
parent | dad8f3aed4ca5f2f93e2be6f1243632439dec541 (diff) |
build: split into libucode and ucode cli
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | CMakeLists.txt | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e9923f1..1f626d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,14 +45,19 @@ IF(JSONC_FOUND) INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS}) ENDIF() -SET(UCODE_SOURCES main.c lexer.c lib.c vm.c chunk.c value.c compiler.c source.c types.c) -ADD_EXECUTABLE(ucode ${UCODE_SOURCES}) -SET_PROPERTY(TARGET ucode PROPERTY ENABLE_EXPORTS 1) -TARGET_LINK_LIBRARIES(ucode ${json}) +SET(UCODE_SOURCES lexer.c lib.c vm.c chunk.c value.c compiler.c source.c types.c) +ADD_LIBRARY(libucode SHARED ${UCODE_SOURCES}) +SET(SOVERSION 0 CACHE STRING "Override ucode library version") +SET_TARGET_PROPERTIES(libucode PROPERTIES OUTPUT_NAME ucode SOVERSION ${SOVERSION}) +TARGET_LINK_LIBRARIES(libucode ${json}) + +SET(CLI_SOURCES main.c) +ADD_EXECUTABLE(ucode ${CLI_SOURCES}) +TARGET_LINK_LIBRARIES(ucode libucode ${json}) CHECK_FUNCTION_EXISTS(dlopen DLOPEN_FUNCTION_EXISTS) IF (NOT DLOPEN_FUNCTION_EXISTS) - TARGET_LINK_LIBRARIES(ucode dl) + TARGET_LINK_LIBRARIES(libucode dl) ENDIF() SET(CMAKE_REQUIRED_LIBRARIES json-c) @@ -114,7 +119,7 @@ IF(UNIT_TESTING) LIST(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") IF(CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_EXECUTABLE(ucode-san ${UCODE_SOURCES}) + ADD_EXECUTABLE(ucode-san ${CLI_SOURCES} ${UCODE_SOURCES}) SET_PROPERTY(TARGET ucode-san PROPERTY ENABLE_EXPORTS 1) TARGET_LINK_LIBRARIES(ucode-san ${json}) TARGET_COMPILE_OPTIONS(ucode-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all) @@ -123,4 +128,5 @@ IF(UNIT_TESTING) ENDIF() INSTALL(TARGETS ucode RUNTIME DESTINATION bin) +INSTALL(TARGETS libucode LIBRARY DESTINATION lib) INSTALL(TARGETS ${LIBRARIES} LIBRARY DESTINATION lib/ucode) |