Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake support #25

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
98 changes: 98 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
project(hdhomerun)
cmake_minimum_required(VERSION 3.0.2)

set(hdhomerun_sources
hdhomerun_channels.c
hdhomerun_channelscan.c
hdhomerun_control.c
hdhomerun_debug.c
hdhomerun_device.c
hdhomerun_device_selector.c
hdhomerun_discover.c
hdhomerun_os_posix.c
hdhomerun_pkt.c
hdhomerun_sock.c
hdhomerun_sock_posix.c
hdhomerun_video.c
)

set(hdhomerun_headers
hdhomerun_channels.h
hdhomerun_channelscan.h
hdhomerun_control.h
hdhomerun_debug.h
hdhomerun_device.h
hdhomerun_device_selector.h
hdhomerun_discover.h
hdhomerun.h
hdhomerun_os.h
hdhomerun_pkt.h
hdhomerun_sock.h
hdhomerun_types.h
hdhomerun_video.h
)

if (WIN32)

set(hdhomerun_sources
${hdhomerun_sources}

hdhomerun_os_windows.c
hdhomerun_sock_netdevice.c
)

set(hdhomerun_headers
${hdhomerun_headers}

hdhomerun_os_windows.h
)

set(hdhomerun_libs iphlpapi ws2_32)

else (WIN32)

set(hdhomerun_headers
${hdhomerun_headers}

hdhomerun_os_posix.h
)

set(hdhomerun_libs pthread)

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(hdhomerun_sources
${hdhomerun_sources}
hdhomerun_sock_netlink.c
)
set(hdhomerun_libs ${hdhomerun_libs} rt)
else()
set(hdhomerun_sources
${hdhomerun_sources}
hdhomerun_sock_getifaddrs.c
)
endif()

if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
set(hdhomerun_libs ${hdhomerun_libs} socket)
endif()
endif ()

add_library(hdhomerun SHARED ${hdhomerun_sources} ${hdhomerun_headers})
target_compile_definitions(hdhomerun PRIVATE -DLIBHDHOMERUN_DLLEXPORT)
target_link_libraries(hdhomerun
PRIVATE
${hdhomerun_libs}
)

install(TARGETS hdhomerun DESTINATION lib)
install(FILES ${hdhomerun_headers} DESTINATION include)

add_executable(hdhomerun_config hdhomerun_config.c)
target_compile_definitions(hdhomerun_config PRIVATE -DLIBHDHOMERUN_DLLIMPORT)
target_link_libraries(hdhomerun_config
PRIVATE
hdhomerun
${hdhomerun_libs}
)

install(TARGETS hdhomerun_config DESTINATION bin)