fix npm auto-corrected some errors in your package.json when publishing.
[liba.git] / cmake / QuickJSPIC.cmake
blobc011989d4c19d459d34e96e928d4edb6926750ed
1 function(QUICKJS_PIC)
2   string(RANDOM RANDOM)
3   set(CMAKETMP ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${RANDOM})
4   file(WRITE ${CMAKETMP}/${RANDOM}.c "#include \"quickjs.h\"
5 JSModuleDef *js_init_module(JSContext *ctx, char const *module_name)
6 {\n\treturn JS_NewCModule(ctx, module_name, 0);\n}
7 ")
8   file(WRITE ${CMAKETMP}/CMakeLists.txt "cmake_minimum_required(VERSION ${CMAKE_VERSION})
9 project(CMAKE_TRY_COMPILE C)\nadd_library(${RANDOM} MODULE ${RANDOM}.c)
10 target_include_directories(${RANDOM} PRIVATE ${QUICKJS_INCLUDE_DIR})
11 target_link_libraries(${RANDOM} PRIVATE ${QUICKJS_LIBRARIES})
13   try_compile(QUICKJS_PIC ${CMAKETMP} ${CMAKETMP} CMAKE_TRY_COMPILE)
14   if(QUICKJS_PIC)
15     set(QUICKJS_PIC 1 CACHE INTERNAL "QuickJS complied with PIC")
16   else()
17     set(QUICKJS_PIC 0 CACHE INTERNAL "QuickJS complied with PIC")
18   endif()
19   file(REMOVE_RECURSE ${CMAKETMP})
20 endfunction()
21 if(NOT DEFINED QUICKJS_PIC)
22   QUICKJS_PIC()
23 endif()