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}
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)
15 set(QUICKJS_PIC 1 CACHE INTERNAL "QuickJS complied with PIC")
17 set(QUICKJS_PIC 0 CACHE INTERNAL "QuickJS complied with PIC")
19 file(REMOVE_RECURSE ${CMAKETMP})
21 if(NOT DEFINED QUICKJS_PIC)