add_library(libproxy SHARED extension_config.cpp extension_pacrunner.cpp extension_wpad.cpp proxy.cpp url.cpp ${LIBPROXY_SOURCES})
if(WIN32)
  target_link_libraries(libproxy modman;ws2_32;${LIBPROXY_LIBRARIES})
else()
  target_link_libraries(libproxy modman;m;pthread;${CMAKE_DL_LIBS};${LIBPROXY_LIBRARIES})
endif()
file(TO_NATIVE_PATH ${MODULE_INSTALL_DIR} MODULE_INSTALL_DIR)
if(WIN32)
  string(REGEX REPLACE "\\\\" "\\\\\\\\" MODULE_INSTALL_DIR ${MODULE_INSTALL_DIR})
endif()

if(IS_ABSOLUTE "${MODULE_INSTALL_DIR}")
  set(MODULEDIR "${MODULE_INSTALL_DIR}")
else ()
  set(MODULEDIR "${CMAKE_INSTALL_PREFIX}/${MODULE_INSTALL_DIR}")
endif()

set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/proxy.cpp
             PROPERTY COMPILE_DEFINITIONS MODULEDIR="${MODULEDIR}";BUILTIN_MODULES=${BUILTIN_MODULES})
# When changing the SOVERSION here remember to also bump the 'favorite proxy .so' in python bindings.
set_target_properties(libproxy PROPERTIES PREFIX "" VERSION 1.0.0 SOVERSION 1)
set_target_properties(libproxy PROPERTIES INTERFACE_LINK_LIBRARIES "")
set_target_properties(libproxy PROPERTIES LINK_INTERFACE_LIBRARIES "")
if(NOT APPLE)
  set_target_properties(libproxy PROPERTIES LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libproxy.map")
endif()
install(TARGETS libproxy DESTINATION ${LIB_INSTALL_DIR})
install(FILES   proxy.h  DESTINATION ${INCLUDE_INSTALL_DIR})
