Skip to content

Commit

Permalink
compile PIC versions of internal libraries, to be used by NCD plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrop7 committed Mar 13, 2013
1 parent 126a47c commit faa7a69
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 61 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@ set(BUILDING_UDEVMONITOR 0)
set(BUILDING_THREADWORK 0)
set(BUILDING_RANDOM 0)

function(badvpn_add_library LIB_NAME LINK_BADVPN_LIBS LINK_SYS_LIBS LIB_SOURCES)
set(BADVPN_LIBS_EXEC)
set(BADVPN_LIBS_PLUGIN)
foreach(LIB ${LINK_BADVPN_LIBS})
list(APPEND BADVPN_LIBS_EXEC "${LIB}")
list(APPEND BADVPN_LIBS_PLUGIN "${LIB}-plugin")
endforeach()

add_library("${LIB_NAME}" STATIC ${LIB_SOURCES})
target_link_libraries("${LIB_NAME}" ${BADVPN_LIBS_EXEC} ${LINK_SYS_LIBS})

add_library("${LIB_NAME}-plugin" STATIC ${LIB_SOURCES})
target_link_libraries("${LIB_NAME}-plugin" ${BADVPN_LIBS_PLUGIN} ${LINK_SYS_LIBS})
set_target_properties("${LIB_NAME}-plugin" PROPERTIES POSITION_INDEPENDENT_CODE YES)
set_target_properties("${LIB_NAME}-plugin" PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
endfunction()

# internal libraries
add_subdirectory(base)
add_subdirectory(system)
Expand Down
3 changes: 2 additions & 1 deletion base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ if (HAVE_SYSLOG_H)
list(APPEND BASE_ADDITIONAL_SOURCES BLog_syslog.c)
endif ()

add_library(base
set(BASE_SOURCES
DebugObject.c
BLog.c
BPending.c
${BASE_ADDITIONAL_SOURCES}
)
badvpn_add_library(base "" "" "${BASE_SOURCES}")
4 changes: 2 additions & 2 deletions flow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(flow
set(FLOW_SOURCES
PacketPassFairQueue.c
PacketPassPriorityQueue.c
PacketPassConnector.c
Expand Down Expand Up @@ -28,4 +28,4 @@ add_library(flow
StreamPassConnector.c
PacketPassFifoQueue.c
)
target_link_libraries(flow base)
badvpn_add_library(flow "base" "" "${FLOW_SOURCES}")
76 changes: 22 additions & 54 deletions ncd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ if (NOT EMSCRIPTEN)
)
endif ()

add_library(ncdinterfacemonitor
extra/NCDInterfaceMonitor.c
)
target_link_libraries(ncdinterfacemonitor base system)
badvpn_add_library(ncdinterfacemonitor "base;system" "" extra/NCDInterfaceMonitor.c)

badvpn_add_library(ncdrequest "base;system;ncdvalgenerator;ncdvalparser" "" extra/NCDRequestClient.c)

add_library(ncdrequest
extra/NCDRequestClient.c
)
target_link_libraries(ncdrequest base system ncdvalgenerator ncdvalparser)

list(APPEND NCD_ADDITIONAL_SOURCES
extra/NCDIfConfig.c
extra/build_cmdline.c
Expand Down Expand Up @@ -73,59 +67,33 @@ if (NOT EMSCRIPTEN)
)
endif ()

add_library(ncdtokenizer
NCDConfigTokenizer.c
)
target_link_libraries(ncdtokenizer base)
badvpn_add_library(ncdtokenizer "base" "" NCDConfigTokenizer.c)

add_library(ncdstringindex
NCDStringIndex.c
)
badvpn_add_library(ncdstringindex "base" "" NCDStringIndex.c)

add_library(ncdval
NCDVal.c
)
target_link_libraries(ncdval base ncdstringindex)
badvpn_add_library(ncdval "base;ncdstringindex" "" NCDVal.c)

add_library(ncdvalgenerator
NCDValGenerator.c
)
target_link_libraries(ncdvalgenerator base ncdval)
badvpn_add_library(ncdvalgenerator "base;ncdval" "" NCDValGenerator.c)

add_library(ncdvalparser
NCDValParser.c
)
target_link_libraries(ncdvalparser base ncdval ncdtokenizer ncdvalcons)
badvpn_add_library(ncdvalparser "base;ncdval;ncdtokenizer;ncdvalcons" "" NCDValParser.c)

add_library(ncdast
NCDAst.c
)
badvpn_add_library(ncdast "" "" NCDAst.c)

add_library(ncdconfigparser
NCDConfigParser.c
)
target_link_libraries(ncdconfigparser base ncdtokenizer ncdast)
badvpn_add_library(ncdconfigparser "base;ncdtokenizer;ncdast" "" NCDConfigParser.c)

add_library(ncdsugar
NCDSugar.c
)
target_link_libraries(ncdsugar ncdast)
badvpn_add_library(ncdsugar "ncdast" "" NCDSugar.c)

add_library(ncdvalcons
NCDValCons.c
)
target_link_libraries(ncdvalcons ncdval)
badvpn_add_library(ncdvalcons "ncdval" "" NCDValCons.c)

add_library(ncdbuildprogram
NCDBuildProgram.c
)
target_link_libraries(ncdbuildprogram base ncdast ncdconfigparser)
badvpn_add_library(ncdbuildprogram "base;ncdast;ncdconfigparser" "" NCDBuildProgram.c)

badvpn_add_library(ncdobject "" "" NCDObject.c)

add_library(ncdinterpreter
badvpn_add_library(ncdmodule "base;ncdobject;ncdstringindex;ncdval" "" NCDModule.c)

set(NCDINTERPRETER_SOURCES
NCDInterpreter.c
NCDModule.c
NCDModuleIndex.c
NCDObject.c
NCDInterpProcess.c
NCDInterpProg.c
NCDPlaceholderDb.c
Expand Down Expand Up @@ -180,10 +148,10 @@ add_library(ncdinterpreter
modules/getenv.c
${NCD_ADDITIONAL_SOURCES}
)
target_link_libraries(ncdinterpreter
system flow flowextra ncdval ncdstringindex ncdvalgenerator ncdvalparser
ncdconfigparser ncdsugar ${NCD_ADDITIONAL_LIBS}
)
set(NCDINTERPRETER_LIBS
base system flow flowextra ncdval ncdstringindex ncdvalgenerator ncdvalparser
ncdconfigparser ncdsugar ncdobject ncdmodule ${NCD_ADDITIONAL_LIBS})
badvpn_add_library(ncdinterpreter "${NCDINTERPRETER_LIBS}" "" "${NCDINTERPRETER_SOURCES}")

if (BADVPN_USE_LINUX_INPUT)
string(REPLACE " " ";" FLAGS_LIST "${CMAKE_C_FLAGS}")
Expand Down
4 changes: 2 additions & 2 deletions system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ elseif (BREACTOR_BACKEND STREQUAL "emscripten")
list(APPEND BSYSTEM_ADDITIONAL_SOURCES BReactor_emscripten.c)
endif ()

add_library(system
set(SYSTEM_SOURCES
BTime.c
${BSYSTEM_ADDITIONAL_SOURCES}
)
target_link_libraries(system base flow ${BSYSTEM_ADDITIONAL_LIBS})
badvpn_add_library(system "base;flow" "${BSYSTEM_ADDITIONAL_LIBS}" "${SYSTEM_SOURCES}")
4 changes: 2 additions & 2 deletions tuntap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ if (WIN32)
list(APPEND TUNTAP_ADDITIONAL_SOURCES tapwin32-funcs.c)
endif ()

add_library(tuntap
set(TUNTAP_SOURCES
BTap.c
${TUNTAP_ADDITIONAL_SOURCES}
)
target_link_libraries(tuntap system flow)
badvpn_add_library(tuntap "system;flow" "" "${TUNTAP_SOURCES}")

0 comments on commit faa7a69

Please sign in to comment.