project (NCam C) #----------------------- minimum version of cmake to use ------------ cmake_minimum_required(VERSION 2.8.12) cmake_policy(SET CMP0003 NEW) if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) endif() if(POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() #----------------------- detect system ------------------------------ if (CMAKE_CROSSCOMPILING) if (NCAM_SYSTEM_NAME MATCHES "Tuxbox") set (NCamOperatingSystem "Tuxbox") elseif (NCAM_SYSTEM_NAME MATCHES "TripleDragon") set (NCamOperatingSystem "TripleDragon") elseif (NCAM_SYSTEM_NAME MATCHES "Coolstream") set (NCamOperatingSystem "NeutrinoHD") elseif (NCAM_SYSTEM_NAME MATCHES "CST2") set (NCamOperatingSystem "NHD2") elseif (NCAM_SYSTEM_NAME MATCHES "NSLU2") set (NCamOperatingSystem "SlugOS") elseif (NCAM_SYSTEM_NAME MATCHES "WRT350NV2") set (NCamOperatingSystem "OpenWRT") set (CS_OS_HW "wrt350nv2") elseif (NCAM_SYSTEM_NAME MATCHES "Dockstar") set (NCamOperatingSystem "OpenWRT") set (CS_OS_HW "dockstar") elseif (NCAM_SYSTEM_NAME MATCHES "OpenWRT") set (NCamOperatingSystem "OpenWRT") elseif (NCAM_SYSTEM_NAME MATCHES "MT7620") set (NCamOperatingSystem "MT7620") elseif (NCAM_SYSTEM_NAME MATCHES "Fonera2") set (NCamOperatingSystem "Fonera2") elseif (NCAM_SYSTEM_NAME MATCHES "DIR-825") set (NCamOperatingSystem "DIR-825") elseif (NCAM_SYSTEM_NAME MATCHES "AZBox") set (NCamOperatingSystem "AZBox") elseif (NCAM_SYSTEM_NAME MATCHES "GXAPI") set (NCamOperatingSystem "GXAPI") elseif (NCAM_SYSTEM_NAME MATCHES "SU980") set (NCamOperatingSystem "SU980") elseif (NCAM_SYSTEM_NAME MATCHES "WETEK") set (NCamOperatingSystem "WETEK") elseif (NCAM_SYSTEM_NAME MATCHES "MCA") set (NCamOperatingSystem "MCA") elseif (NCAM_SYSTEM_NAME MATCHES "agv2+w") set (NCamOperatingSystem "agv2+w") elseif (NCAM_SYSTEM_NAME MATCHES "WRT54G") set (NCamOperatingSystem "WRT54G") elseif (NCAM_SYSTEM_NAME MATCHES "Amino") set (NCamOperatingSystem "Amino") elseif (NCAM_SYSTEM_NAME MATCHES "QboxHD") set (NCamOperatingSystem "QboxHD") elseif (NCAM_SYSTEM_NAME MATCHES "Padre") set (NCamOperatingSystem "Padre") elseif (NCAM_SYSTEM_NAME MATCHES "FriendlyARM") set (NCamOperatingSystem "FriendlyARM") elseif (NCAM_SYSTEM_NAME MATCHES "Android") set (NCamOperatingSystem "Android") elseif (NCAM_SYSTEM_NAME MATCHES "Raspbian") set (NCamOperatingSystem "Raspbian") elseif (${CYGWIN}) set (NCamOperatingSystem "Windows/Cygwin") set (CS_OS_HW "pc") set (CS_OS_SYS "cygwin") set (CMAKE_SYSTEM_PROCESSOR "i386") else (NCAM_SYSTEM_NAME MATCHES "Tuxbox") message (STATUS "Unknown cross system name: <${CMAKE_SYSTEM_NAME}>") set (NCamOperatingSystem "Unknown") endif (NCAM_SYSTEM_NAME MATCHES "Tuxbox") else (CMAKE_CROSSCOMPILING) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") set (NCamOperatingSystem "Linux") elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set (NCamOperatingSystem "FreeBSD") elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") set (NCamOperatingSystem "OpenBSD") elseif (NCamOperatingSystem MATCHES "Padre") add_definitions ("-DPADRE -DSPARC") set (DEFAULT_CS_CONFDIR "/etc/ncam") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set (NCamOperatingSystem "Mac OS X") execute_process(COMMAND sw_vers -productVersion COMMAND cut -c 1-4 COMMAND tr -d '\n' OUTPUT_VARIABLE SWVER) execute_process(COMMAND xcodebuild -version COMMAND grep Xcode COMMAND sed "s/Xcode\ //g" COMMAND tr -d '\n' OUTPUT_VARIABLE XCODEVER) message (STATUS "mac sdk version is ${SWVER}") message (STATUS "mac Xcode version is ${XCODEVER}") add_definitions ("-w") set (CMAKE_OSX_DEPLOYMENT_TARGET "${SWVER}") if (SWVER GREATER 10.5) set (CMAKE_OSX_ARCHITECTURES "x86_64") endif (SWVER GREATER 10.5) if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3) message (STATUS "Compiling with xcode less then 4.3 on 10.7 If You have time update You're Xcode") endif (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3) set (STATIC_LIBUSB True) elseif (${CYGWIN}) set (NCamOperatingSystem "Windows/Cygwin") set (CMAKE_SYSTEM_PROCESSOR "i386") else (${CMAKE_SYSTEM_NAME} MATCHES "Linux") message (STATUS "Unknown system name: <${CMAKE_SYSTEM_NAME}>") set (NCamOperatingSystem "Unknown") endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") endif (CMAKE_CROSSCOMPILING) #----------------------- some paths ------------------------------ set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories") set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories") if (NCamOperatingSystem MATCHES "Windows/Cygwin") include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/csctapi ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt ${CMAKE_CURRENT_SOURCE_DIR}/minilzo ${CMAKE_CURRENT_SOURCE_DIR}/ffdecsa ${CMAKE_CURRENT_SOURCE_DIR}/extapi/cygwin /usr/include/w32api ${OPTIONAL_INCLUDE_DIR} ) else (NCamOperatingSystem MATCHES "Windows/Cygwin") include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/csctapi ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt ${CMAKE_CURRENT_SOURCE_DIR}/minilzo ${CMAKE_CURRENT_SOURCE_DIR}/ffdecsa ${OPTIONAL_INCLUDE_DIR} ) endif (NCamOperatingSystem MATCHES "Windows/Cygwin") if(NCamOperatingSystem MATCHES "Windows/Cygwin") link_directories ( /usr/lib /usr/lib/w32api /cygdrive/c/WINDOWS/system32/ ${OPTIONAL_LINK_DIR} ) else (NCamOperatingSystem MATCHES "Windows/Cygwin") link_directories ( ${OPTIONAL_LINK_DIR} ) endif (NCamOperatingSystem MATCHES "Windows/Cygwin") #----------------------- global options ------------------------------ if (NCamOperatingSystem MATCHES "Linux") set (DEFAULT_CS_CONFDIR "/usr/local/etc") set (dl_link "dl") elseif (NCamOperatingSystem MATCHES "Mac OS X") if (NOT HAVE_PCSC EQUAL 0) add_definitions ("-DWITH_PCSC=1") endif (NOT HAVE_PCSC EQUAL 0) set (DEFAULT_CS_CONFDIR "/usr/local/etc") elseif (NCamOperatingSystem MATCHES "Android") set (DEFAULT_CS_CONFDIR "/data/plugin/ncamemu") if(ANDROID_ABI STREQUAL armeabi-v7a) set(CS_TARGET arm-linux-androideabi) elseif(ANDROID_ABI STREQUAL arm64-v8a) set(CS_TARGET aarch64-linux-android) elseif(ANDROID_ABI STREQUAL x86) set(CS_TARGET i686-linux-android) elseif(ANDROID_ABI STREQUAL x86_64) set(CS_TARGET x86_64-linux-android) else() message(FATAL_ERROR "Invalid Android ABI: ${ANDROID_ABI}.") endif() elseif (NCamOperatingSystem MATCHES "Raspbian") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") elseif (NCamOperatingSystem MATCHES "Tuxbox") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") set (dl_link "dl") elseif (NCamOperatingSystem MATCHES "TripleDragon") add_definitions ("-DSTB04SCI=1") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") set (dl_link "dl") elseif (NCamOperatingSystem MATCHES "NeutrinoHD") add_definitions ("-DWITH_COOLAPI=1") set (USE_COOLAPI "USE_COOLAPI") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") elseif (NCamOperatingSystem MATCHES "NHD2") add_definitions ("-DWITH_COOLAPI2=1") set (USE_COOLAPI2 "USE_COOLAPI2") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") elseif (NCamOperatingSystem MATCHES "SlugOS") set (DEFAULT_CS_CONFDIR "/var/etc") elseif (NCamOperatingSystem MATCHES "OpenWRT") if (CS_OS_HW MATCHES "wrt350nv2") set (DEFAULT_CS_CONFDIR "/etc/ncam") elseif (CS_OS_HW MATCHES "dockstar") set (DEFAULT_CS_CONFDIR "/usr/ncam") else (CS_OS_HW MATCHES "wrt350nv2") set (DEFAULT_CS_CONFDIR "/etc/ncam") endif (CS_OS_HW MATCHES "wrt350nv2") set (dl_link "dl") elseif (NCamOperatingSystem MATCHES "MT7620") set (DEFAULT_CS_CONFDIR "/etc/ncam") set (dl_link "dl") elseif (NCamOperatingSystem MATCHES "Fonera2") set (DEFAULT_CS_CONFDIR "/var/etc") elseif (NCamOperatingSystem MATCHES "DIR-825") set (DEFAULT_CS_CONFDIR "/var/etc") elseif (NCamOperatingSystem MATCHES "AZBox") add_definitions ("-DWITH_AZBOX=1") set (USE_AZBOX "USE_AZBOX") set (DEFAULT_CS_CONFDIR "/PLUGINS/OpenXCAS/ncamCAS") elseif (NCamOperatingSystem MATCHES "GXAPI") add_definitions ("-DWITH_GXAPI=1") add_definitions ("-I${CMAKE_CURRENT_SOURCE_DIR}/extapi/goceed") set (USE_GXAPI "USE_GXAPI") set (DEFAULT_CS_CONFDIR "/home/gx/ncam") elseif (NCamOperatingSystem MATCHES "SU980") set (USE_SU980 "USE_SU980") add_definitions ("-DWITH_SU980=1") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") elseif (NCamOperatingSystem MATCHES "WETEK") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") elseif (NCamOperatingSystem MATCHES "MCA") add_definitions ("-DWITH_MCA=1") set (USE_MCA "USE_MCA") set (DEFAULT_CS_CONFDIR "/var/mca/d1") elseif (NCamOperatingSystem MATCHES "agv2+w") set (DEFAULT_CS_CONFDIR "/etc") elseif (NCamOperatingSystem MATCHES "WRT54G") set (DEFAULT_CS_CONFDIR "/jffs/etc/config/ncam") elseif (NCamOperatingSystem MATCHES "Amino") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") elseif (NCamOperatingSystem MATCHES "QboxHD") add_definitions ("-DQBOXHD=1") set (DEFAULT_CS_CONFDIR "/var/tuxbox/config") elseif (NCamOperatingSystem MATCHES "Windows/Cygwin") add_definitions ("-static -DWITH_PCSC=1") set (DEFAULT_CS_CONFDIR ".") elseif (NCamOperatingSystem MATCHES "FreeBSD") add_definitions ("-I/usr/local/include -L/usr/local/lib") set (DEFAULT_CS_CONFDIR ".") elseif (NCamOperatingSystem MATCHES "OpenBSD") add_definitions ("-I/usr/local/include -L/usr/local/lib") set (DEFAULT_CS_CONFDIR "/etc/ncam") elseif (NCamOperatingSystem MATCHES "FriendlyARM") set (DEFAULT_CS_CONFDIR ".") endif (NCamOperatingSystem MATCHES "Linux") set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files") add_definitions ("-D'CS_CONFDIR=\"${CS_CONFDIR}\"'") if (dl_link) add_definitions("-DWITH_DL") set(WITH_DL True) else(dl_link) set(WITH_DL False) endif(dl_link) #----------------------- subdirectories ------------------------------ include (CheckIncludeFile) check_include_file ("pthread.h" HAVE_PTHREAD) if (HAVE_PTHREAD) message(STATUS " pthread found. Adding pthread support ") add_definitions ("-DHAVE_PTHREAD_H") elseif (HAVE_PTHREAD) message(STATUS " no pthread found. No smartreader ") endif (HAVE_PTHREAD) check_include_file ("openssl/aes.h" HAVE_LIBCRYPTO) if (HAVE_LIBCRYPTO) add_definitions ("-DWITH_LIBCRYPTO=1") set (USE_LIBCRYPTO "USE_LIBCRYPTO") else (HAVE_LIBCRYPTO) message (STATUS " LIBCRYTO NOT FOUND OR DISABLED NO SSL SUPPORT POSSIBLE") endif (HAVE_LIBCRYPTO) if (USE_LIBCRYPTO AND STATIC_LIBCRYPTO AND LIBCRYPTODIR) if (EXISTS ${LIBCRYPTODIR}/lib/libcrypto.a) message(STATUS " static libcrypto found.") set(STATIC_LIBCRYPTO True) add_library(imp_libcrypto STATIC IMPORTED) set_property(TARGET imp_libcrypto PROPERTY IMPORTED_LOCATION ${LIBCRYPTODIR}/lib/libcrypto.a) else (EXISTS ${LIBCRYPTODIR}/lib/libcrypto.a) set(STATIC_LIBCRYPTO False) endif (EXISTS ${LIBCRYPTODIR}/lib/libcrypto.a) else (USE_LIBCRYPTO AND STATIC_LIBCRYPTO AND LIBCRYPTODIR) set(STATIC_LIBCRYPTO False) endif (USE_LIBCRYPTO AND STATIC_LIBCRYPTO AND LIBCRYPTODIR) execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_SSL OUTPUT_VARIABLE CONFIG_WITH_SSL OUTPUT_STRIP_TRAILING_WHITESPACE) if (CONFIG_WITH_SSL MATCHES "N" AND WITH_SSL EQUAL 1) message ( STATUS " ssl is added by You compiling with ssl included") elseif (CONFIG_WITH_SSL MATCHES "Y" AND WITH_SSL EQUAL 1) message (STATUS " ssl is added by You but it was already enabled by config file") elseif (CONFIG_WITH_SSL MATCHES "N" AND NOT WITH_SSL EQUAL 1) message (STATUS " SSL IS NOT INCLUDED IN THIS COMPILATION") endif (CONFIG_WITH_SSL MATCHES "N" AND WITH_SSL EQUAL 1) if (CONFIG_WITH_SSL MATCHES "Y" AND NOT WITH_SSL EQUAL 0) message(status " SSL is added by config file ${CONFIG_WITH_SSL} compiling with ssl included") add_definitions ("-DWITH_SSL") set (WITH_SSL "1") elseif (CONFIG_WITH_SSL MATCHES "Y" AND WITH_SSL EQUAL 0) message (status " The config file has ssl enabled, but You disabled it by you cmake command COMPILING WHITOUT SSL") endif (CONFIG_WITH_SSL MATCHES "Y" AND NOT WITH_SSL EQUAL 0) find_package(OpenSSL) if (OPENSSL_FOUND AND HAVE_LIBCRYPTO) include_directories(${OPENSSL_INCLUDE_DIR}) message(STATUS " openssl found.") if (WITH_SSL EQUAL 1) set(USE_SSL "USE_SSL") endif (WITH_SSL EQUAL 1) else (OPENSSL_FOUND AND HAVE_LIBCRYPTO) message(STATUS "SSL REQUESTED BUT OPENSSL or LYBCRYPTO NOT FOUND !!") if (WITH_SSL) message(STATUS " ssl support requested but openssl or libcrypto NOT FOUND COMPILING WHITOUT SSL !!! ") set (WITH_SSL "0") endif (WITH_SSL) endif (OPENSSL_FOUND AND HAVE_LIBCRYPTO) if (USE_SSL AND STATIC_LIBSSL AND LIBSSLDIR AND STATIC_LIBCRYPTO) if (EXISTS ${LIBSSLDIR}/lib/libssl.a) message(STATUS " static libssl found.") set(STATIC_SSL True) add_library(imp_libssl STATIC IMPORTED) set_property(TARGET imp_libssl PROPERTY IMPORTED_LOCATION ${LIBSSLDIR}/lib/libssl.a) else (EXISTS ${LIBSSLDIR}/lib/libssl.a) set(STATIC_SSL False) endif (EXISTS ${LIBSSLDIR}/lib/libssl.a) else (USE_SSL AND STATIC_LIBSSL AND LIBSSLDIR AND STATIC_LIBCRYPTO) set(STATIC_SSL False) endif (USE_SSL AND STATIC_LIBSSL AND LIBSSLDIR AND STATIC_LIBCRYPTO) if (NOT NCamOperatingSystem MATCHES "Mac OS X") if (LIBRTDIR) check_include_file ("${LIBRTDIR}/include/sys/time.h" HAVE_LIBRT_STATIC) if (HAVE_LIBRT_STATIC) if (EXISTS ${LIBRTDIR}/lib/librt.a) message(STATUS " static librt found : ${LIBRTDIR}/lib/librt.a (needed by libusb).") add_definitions ("-I${LIBRTDIR}/include/") add_library(imp_librt STATIC IMPORTED) set_property(TARGET imp_librt PROPERTY IMPORTED_LOCATION ${LIBRTDIR}/lib/librt.a) else (EXISTS ${LIBRTDIR}/lib/librt.a) message(STATUS " ${LIBRTDIR}/lib/librt.a not found (needed by libusb). No smartreader support)") set (HAVE_LIBRT_STATIC False) endif (EXISTS ${LIBRTDIR}/lib/librt.a) else (HAVE_LIBRT_STATIC) message(STATUS " no librt found (needed by libusb). No smartreader support") endif (HAVE_LIBRT_STATIC) else (LIBRTDIR) check_include_file ("time.h" HAVE_LIBRT) if (HAVE_LIBRT) message(STATUS " librt found (needed by libusb).") else (HAVE_LIBRT) message(STATUS " no librt found (needed by libusb. No smartreader support") endif (HAVE_LIBRT) endif (LIBRTDIR) if (WITH_STAPI) if (NOT NCamOperatingSystem MATCHES "Android") if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a) message(STATUS " liboscam_stapi.a found") add_definitions ("-DWITH_STAPI=1") add_library(stapilib STATIC IMPORTED) set_property(TARGET stapilib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a) set (HAVE_LIBSTAPI True) set (USE_STAPI "USE_STAPI") else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a) message(FATAL " liboscam_stapi.a support requested but not found! ") set (HAVE_LIBSTAPI False) endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a) else (NOT NCamOperatingSystem MATCHES "Android") if (WI_OLD) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/libwi_old.a) message(STATUS " libwi_old.a found") add_definitions ("-DWITH_STAPI=1") add_definitions ("-DWITH_WI=1") add_definitions ("-DWI_OLD=1") add_definitions ("-I${CMAKE_CURRENT_SOURCE_DIR}/stapi/include/") add_library(stapilib STATIC IMPORTED) set_property(TARGET stapilib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/stapi/libwi_old.a) set (HAVE_LIBSTAPI True) set (USE_STAPI "USE_STAPI") else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/libwi_old.a) message(FATAL " libwi_old.a support requested but not found! ") set (HAVE_LIBSTAPI False) endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/libwi_old.a) else (WI_OLD) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/libwi.a) message(STATUS " libwi.a found") add_definitions ("-DWITH_STAPI=1") add_definitions ("-DWITH_WI=1") add_definitions ("-I${CMAKE_CURRENT_SOURCE_DIR}/stapi/include/") add_library(stapilib STATIC IMPORTED) set_property(TARGET stapilib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/stapi/libwi.a) set (HAVE_LIBSTAPI True) set (USE_STAPI "USE_STAPI") else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/libwi.a) message(FATAL " libwi.a support requested but not found! ") set (HAVE_LIBSTAPI False) endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/libwi.a) endif (WI_OLD) endif (NOT NCamOperatingSystem MATCHES "Android") endif (WITH_STAPI) if (WITH_STAPI5) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a) message(STATUS " liboscam_stapi5.a found") add_definitions ("-DWITH_STAPI5=1") add_library(stapi5lib STATIC IMPORTED) set_property(TARGET stapi5lib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a) set (HAVE_LIBSTAPI5 True) set (USE_STAPI5 "USE_STAPI5") else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a) message(FATAL " liboscam_stapi5.a support requested but not found! ") set (HAVE_LIBSTAPI5 False) endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a) endif (WITH_STAPI5) else (NOT NCamOperatingSystem MATCHES "Mac OS X") set (HAVE_LIBRT True) endif (NOT NCamOperatingSystem MATCHES "Mac OS X") if( HAVE_LIBRT OR HAVE_LIBRT_STATIC) if (LIBUSBDIR) check_include_file ("${LIBUSBDIR}/include/libusb-1.0/libusb.h" HAVE_LIBUSB) if (HAVE_LIBUSB AND HAVE_PTHREAD) if (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a) if (STATIC_LIBUSB EQUAL 1) message(STATUS " libusb 1.0 found (${LIBUSBDIR}/lib/libusb-1.0.a). Adding smartreader support ") add_definitions ("-DWITH_LIBUSB=1") add_definitions ("-I${LIBUSBDIR}/include/") set (LIBUSB "USE_LIBUSB") add_library(imp_libusb STATIC IMPORTED) set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSBDIR}/lib/libusb-1.0.a) elseif (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0) set (CMAKE_FIND_ROOT_PATH ${LIBUSBDIR}) find_library (LIBUSB_LIBRARY NAMES usb-1.0) message(STATUS "libusb 1.0 found (${LIBUSB_LIBRARY}). Adding smartreader support ") add_definitions ("-DWITH_LIBUSB=1") add_definitions ("-I${LIBUSBDIR}/include/") set (LIBUSB "USE_LIBUSB") add_library(imp_libusb SHARED IMPORTED) set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSB_LIBRARY} ) endif (STATIC_LIBUSB EQUAL 1) else (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a) message(STATUS " libusb 1.0 not found (${LIBUSBDIR}/lib/libusb). No smartreader support ") set (HAVE_LIBUSB False) set (HAVE_LIBRT False) set (HAVE_LIBRT_STATIC False) endif (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a) else (HAVE_LIBUSB AND HAVE_PTHREAD) message(STATUS " no libusb 1.0 found. No smartreader support") set (HAVE_LIBUSB False) set (HAVE_LIBRT False) set (HAVE_LIBRT_STATIC False) endif (HAVE_LIBUSB AND HAVE_PTHREAD) else (LIBUSBDIR) if (NOT HAVE_LIBUSB EQUAL 0) check_include_file ("libusb-1.0/libusb.h" HAVE_LIBUSB) check_include_file ("libusb-1.0/libusb.h" PRESENT) endif(NOT HAVE_LIBUSB EQUAL 0) if (NCamOperatingSystem MATCHES "Mac OS X") if (NOT HAVE_LIBUSB EQUAL 0 AND NOT PRESENT) find_file (USBINCL_LOC "libusb-1.0/libusb.h") if (EXISTS ${USBINCL_LOC}) add_definitions ("-I/usr/local/include -L/usr/local/lib -I/usr/include -L/usr/lib") set (HAVE_LIBUSB True) set (PRESENT True) set (USE_LIBUSB "USE_LIBUSB") if (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0) set (STATICLIBUSB False) elseif (STATIC_LIBUSB EQUAL 1) set (STATICLIBUSB True) endif (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0) endif (EXISTS ${USBINCL_LOC}) endif (NOT HAVE_LIBUSB EQUAL 0 AND NOT PRESENT) endif (NCamOperatingSystem MATCHES "Mac OS X") if (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0) if(HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT) message(STATUS " libusb 1.0 found (libusb-1.0.so) Adding smartreader support ") add_definitions ("-DWITH_LIBUSB=1") set (USE_LIBUSB "USE_LIBUSB") set (STATICLIBUSB False) endif(HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT) elseif(STATIC_LIBUSB EQUAL 1) if (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT) message(STATUS " static libusb 1.0 found (libusb-1.0.a). Adding smartreader support ") add_definitions ("-DWITH_LIBUSB=1") set (USE_LIBUSB "USE_LIBUSB") set (STATICLIBUSB True) else (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT) message(STATUS " no libusb 1.0 found. No smartreader support") set (HAVE_LIBUSB False) endif (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT) endif(NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0) endif (LIBUSBDIR) endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC) if (NOT WITH_PCSC EQUAL 0 OR HAVE_PCSC EQUAL 0) check_include_file ("PCSC/wintypes.h" HAVE_PCSC) if ((NOT HAVE_PCSC) AND OPTIONAL_INCLUDE_DIR) check_include_file("${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h" HAVE_PCSC) endif((NOT HAVE_PCSC) AND OPTIONAL_INCLUDE_DIR) else (NOT WITH_PCSC EQUAL 0 OR HAVE_PCSC EQUAL 0) set (HAVE_PCSC False) endif (NOT WITH_PCSC EQUAL 0 OR HAVE_PCSC EQUAL 0) if (HAVE_PCSC) FIND_PATH (PCSC_PATH PCSC/wintypes.h) if(OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h) message(STATUS " PCSC headers found (${OPTIONAL_INCLUDE_DIR}/PCSC). Adding PCSC support ") add_definitions ("-DWITH_PCSC=1") add_definitions ("-I${OPTIONAL_INCLUDE_DIR}/PCSC") set (USE_PCSC "USE_PCSC") elseif (EXISTS ${PCSC_PATH}/PCSC/wintypes.h AND NOT OPTIONAL_INCLUDE_DIR) message(STATUS " PCSC headers found (${PCSC_PATH}/PCSC). Adding PCSC support ") add_definitions ("-DWITH_PCSC=1") add_definitions ("-I${PCSC_PATH}/PCSC") set (USE_PCSC "USE_PCSC") else (OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h) if (NOT NCamOperatingSystem MATCHES "Mac OS X") set (HAVE_PCSC False) if(OPTIONAL_INCLUDE_DIR) message(STATUS " PCSC headers not found (not in /usr/include/PCSC or /usr/local/include/PCSC or ${OPTIONAL_INCLUDE_DIR}/PCSC). No PCSC support ") else(OPTIONAL_INCLUDE_DIR) message(STATUS " PCSC headers not found (not in /usr/include/PCSC or /usr/local/include/PCSC). No PCSC support ") endif(OPTIONAL_INCLUDE_DIR) endif (NOT NCamOperatingSystem MATCHES "Mac OS X") endif(OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h) if (NCamOperatingSystem MATCHES "Mac OS X" AND NOT HAVE_PCSC EQUAL 0) set (USE_PCSC "USE_PCSC") set (HAVE_PCSC "1") endif (NCamOperatingSystem MATCHES "Mac OS X" AND NOT HAVE_PCSC EQUAL 0) else (HAVE_PCSC) if (NCamOperatingSystem MATCHES "Windows/Cygwin") add_definitions ("-Icygwin") set (HAVE_PCSC "1") set (USE_PCSC "USE_PCSC") endif (NCamOperatingSystem MATCHES "Windows/Cygwin") endif (HAVE_PCSC) if (HAVE_PCSC AND USE_PCSC) if (NOT NCamOperatingSystem MATCHES "Windows/Cygwin") if (STATIC_LIBPCSC EQUAL 1) if (EXISTS ${LIBPCSCDIR}/lib/libpcsclite.a) message(STATUS " libpcsclite found (${LIBPCSCDIR}/lib/libpcsclite.a). Adding smartreader support ") add_library(imp_libpcsclite STATIC IMPORTED) set_property(TARGET imp_libpcsclite PROPERTY IMPORTED_LOCATION ${LIBPCSCDIR}/lib/libpcsclite.a) set (STATIC_LIBPCSC True) set (libpcsc_link "imp_libpcsclite") add_definitions("-DSTATIC_LIBPCSC") else (EXISTS ${LIBPCSCDIR}/lib/libpcsclite.a) set(STATIC_LIBPCSC False) set(libpcsc_link pcsclite) endif (EXISTS ${LIBPCSCDIR}/lib/libpcsclite.a) else (STATIC_LIBPCSC EQUAL 1) set(STATIC_LIBPCSC False) set(libpcsc_link pcsclite) endif (STATIC_LIBPCSC EQUAL 1) endif (NOT NCamOperatingSystem MATCHES "Windows/Cygwin") else (HAVE_PCSC AND USE_PCSC) set (STATIC_LIBPCSC False) endif (HAVE_PCSC AND USE_PCSC) check_include_file ("curl/curl.h" HAVE_LIBCURL) if (HAVE_LIBCURL) if (EXISTS ${LIBCURLDIR}/lib/libcurl.a) if (STATIC_LIBCURL EQUAL 1) message(STATUS " libcurl found (${LIBCURLDIR}/lib/libcurl.a). Adding curl support ") add_definitions ("-DWITH_LIBCURL=1") add_definitions ("-I${LIBCURLDIR}/include/") set (LIBCURL "USE_LIBCURL=1") add_library(imp_libcurl STATIC IMPORTED) set_property(TARGET imp_libcurl PROPERTY IMPORTED_LOCATION ${LIBCURLDIR}/lib/libcurl.a) set (STATIC_LIBCURL True) set (libcurl_link "imp_libcurl") add_definitions("-lcurl") elseif (NOT STATIC_LIBCURL OR STATIC_LIBCURL EQUAL 0) find_library (LIBCURL_LIBRARY NAMES curl) message(STATUS " libcurl found (${LIBCURL_LIBRARY}). Adding curl support ") add_definitions ("-DWITH_LIBCURL=1") add_definitions ("-I${LIBCURLDIR}/include/") set (LIBCURL "USE_LIBCURL=1") add_library(imp_libcurl SHARED IMPORTED) set_property(TARGET imp_libcurl PROPERTY IMPORTED_LOCATION ${LIBCURL_LIBRARY} ) set(STATIC_LIBCURL False) set(libcurl_link curl) endif (STATIC_LIBCURL EQUAL 1) else (EXISTS ${LIBCURLDIR}/lib/libcurl.a) find_library (LIBCURL_LIBRARY NAMES curl) message(STATUS " libcurl found (${LIBCURL_LIBRARY}). Adding curl support ") add_definitions ("-DWITH_LIBCURL=1") add_definitions ("-I${LIBCURLDIR}/include/") set (LIBCURL "USE_LIBCURL=1") add_library(imp_libcurl SHARED IMPORTED) set_property(TARGET imp_libcurl PROPERTY IMPORTED_LOCATION ${LIBCURL_LIBRARY} ) set(STATIC_LIBCURL False) set(libcurl_link curl) endif (EXISTS ${LIBCURLDIR}/lib/libcurl.a) elseif (HAVE_LIBCURL) message(STATUS " no curl found. ") endif (HAVE_LIBCURL) # Manage config.h based on command line parameters # Manipulate config file based on given parameters and read unset parameters execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_EMU OUTPUT_VARIABLE CONFIG_WITH_EMU OUTPUT_STRIP_TRAILING_WHITESPACE) if (CONFIG_WITH_EMU MATCHES "Y" AND NOT WITH_EMU EQUAL 1) add_definitions ("-DWITH_EMU") set (WITH_EMU "1") message (STATUS " EMU is added by config compiling with EMU") endif (CONFIG_WITH_EMU MATCHES "Y" AND NOT WITH_EMU EQUAL 1) if (WITH_EMU) execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_SOFTCAM OUTPUT_VARIABLE CONFIG_WITH_SOFTCAM OUTPUT_STRIP_TRAILING_WHITESPACE) if (CONFIG_WITH_SOFTCAM MATCHES "Y" AND NOT WITH_SOFTCAM EQUAL 1) add_definitions ("-DWITH_SOFTCAM") set (WITH_SOFTCAM "1") message (STATUS " SOFTCAM is added by config linking SoftCam.Key") endif (CONFIG_WITH_SOFTCAM MATCHES "Y" AND NOT WITH_SOFTCAM EQUAL 1) endif (WITH_EMU) execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --show-valid OUTPUT_VARIABLE config_vars_string OUTPUT_STRIP_TRAILING_WHITESPACE) string(REGEX MATCHALL "[A-Z0-9_]+" config_vars ${config_vars_string}) MACRO(GENERATE_NCAM_CONFIG fullpath) foreach(option ${config_vars}) if(DEFINED ${option}) if(${option}) execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enable ${option}) else(${option}) execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --disable ${option}) endif(${option}) endif(DEFINED ${option}) endforeach(option) ENDMACRO(GENERATE_NCAM_CONFIG fullpath) GENERATE_NCAM_CONFIG("${CMAKE_CURRENT_SOURCE_DIR}/config.h") # Build config.mak and related files # FIXME: Create USE_FLAGS and pass them to config.sh using --use-flags execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --objdir ${CMAKE_CURRENT_BINARY_DIR} --use-flags "${USE_STAPI} ${USE_STAPI5} / ${USE_COOLAPI} ${USE_SU980} ${USE_WETEK} ${USE_AZBOX} ${USE_GXAPI} ${USE_MCA} ${USE_SSL} ${USE_LIBCRYPTO} ${USE_LIBUSB} ${USE_PCSC} ${USE_LIBCURL}" --make-config.mak) # Generate webif/pages.c execute_process (COMMAND make --no-print-directory --quiet -C ${CMAKE_CURRENT_SOURCE_DIR}/webif) #----------------------- subdirectories ------------------------------ add_subdirectory (csctapi) add_subdirectory (minilzo) add_subdirectory (cscrypt) add_subdirectory (ffdecsa) #----------------------- file groups ------------------------------ execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled MODULE_CAMD33 OUTPUT_VARIABLE CAMD33 OUTPUT_STRIP_TRAILING_WHITESPACE) if (CAMD33 MATCHES "N") set (CAMD_33 "module-camd33*") endif (CAMD33 MATCHES "N") if (NCamOperatingSystem MATCHES "Mac OS X") file (GLOB csmodules_mac "module-dvbapi*" "module-lcd*" "${CAMD_33}") file (GLOB csmodules_srcs "module-*.c" "webif/pages.c") list (REMOVE_ITEM csmodules_srcs ${csmodules_mac}) file (GLOB csmodules_hdrs "module-*.h" "webif/pages.h") list (REMOVE_ITEM csmodules_hdrs ${csmodules_mac}) file (GLOB csreaders_srcs "reader-*.c") file (GLOB csreaders_hdrs "reader-*.h") file (GLOB csncam_srcs "ncam-*.c") file (GLOB csncam_hdrs "ncam-*.h") file (GLOB exe_srcs "ncam.c") file (GLOB exe_hdrs "globals.h") file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csncam_srcs} ${exe_srcs}) else (NCamOperatingSystem MATCHES "Mac OS X") file (GLOB csmodules_srcs "module-*.c" "webif/pages.c") file (GLOB csmodules_hdrs "module-*.h" "webif/pages.h") file (GLOB csreaders_srcs "reader-*.c") file (GLOB csreaders_hdrs "reader-*.h") file (GLOB csncam_srcs "ncam-*.c" "${CMAKE_CURRENT_BINARY_DIR}/config.c") file (GLOB csncam_hdrs "ncam-*.h") file (GLOB exe_srcs "ncam.c") file (GLOB exe_hdrs "globals.h") file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csncam_srcs} ${exe_srcs}) endif (NCamOperatingSystem MATCHES "Mac OS X") #----------------------- modules ------------------------------ set (csmodules "csmodules") add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs}) #----------------------- readers ------------------------------ set (csreaders "csreaders") add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs}) #----------------------- other ncam files ------------------------------ set (csncam "csncam") add_library (${csncam} STATIC ${csncam_srcs} ${csncam_hdrs}) #----------------------- the executable ------------------------------ set (exe_name "ncam") add_executable (${exe_name} ${exe_srcs} ${exe_hdrs}) target_link_libraries (${exe_name} ${csncam} ${csmodules} ${csreaders} csctapi cscrypt minilzo ffdecsa) if(HAVE_LIBRT AND HAVE_LIBUSB) if (LIBUSBDIR) set (libusb_link "imp_libusb") else(LIBUSBDIR) if (STATICLIBUSB) set (libusb_link "libusb-1.0.a") else (STATICLIBUSB) set (libusb_link "usb-1.0") endif(STATICLIBUSB) endif(LIBUSBDIR) if (NOT NCamOperatingSystem MATCHES "(Mac OS X|Android)") set (rt_link "rt") endif (NOT NCamOperatingSystem MATCHES "(Mac OS X|Android)") if (NCamOperatingSystem MATCHES "Windows/Cygwin") set (setupapi_link "setupapi") set (ole32_link "ole32") set (shell32_link "shell32") endif (NCamOperatingSystem MATCHES "Windows/Cygwin") endif(HAVE_LIBRT AND HAVE_LIBUSB) if (HAVE_LIBRT_STATIC AND HAVE_LIBUSB) if (LIBUSBDIR) set (libusb_link "imp_libusb") else(LIBUSBDIR) if (STATICLIBUSB) set (libusb_link "libusb-1.0.a") else (STATICLIBUSB) set (libusb_link "usb-1.0") endif(STATICLIBUSB) endif(LIBUSBDIR) if (NOT NCamOperatingSystem MATCHES "(Mac OS X|Android)") set (rt_link "imp_librt") set (USE_LIBRT_STATIC True) endif (NOT NCamOperatingSystem MATCHES "(Mac OS X|Android)") if (NCamOperatingSystem MATCHES "Windows/Cygwin") set (setupapi_link "setupapi") set (ole32_link "ole32") set (shell32_link "shell32") endif (NCamOperatingSystem MATCHES "Windows/Cygwin") endif (HAVE_LIBRT_STATIC AND HAVE_LIBUSB) if (HAVE_PTHREAD) if (NCamOperatingSystem MATCHES "Windows/Cygwin") set (pthread_link "pthread") else (NCamOperatingSystem MATCHES "Windows/Cygwin") set (pthread_link "-pthread") endif (NCamOperatingSystem MATCHES "Windows/Cygwin") endif (HAVE_PTHREAD) if (WITH_SSL) if (STATIC_LIBSSL AND NOT NCamOperatingSystem MATCHES "Windows/Cygwin") set(ssl_link "imp_libssl") else (STATIC_LIBSSL AND NOT NCamOperatingSystem MATCHES "Windows/Cygwin") target_link_libraries (${exe_name} ssl) endif (STATIC_LIBSSL AND NOT NCamOperatingSystem MATCHES "Windows/Cygwin") endif (WITH_SSL) if (HAVE_LIBCRYPTO) if (STATIC_LIBCRYPTO) set(crypto_link "imp_libcrypto") else (STATIC_LIBCRYPTO) target_link_libraries (${exe_name} crypto) endif (STATIC_LIBCRYPTO) endif (HAVE_LIBCRYPTO) # some systems need libm for the nagra cak7 functions to work check_include_file("math.h" HAVE_LIBM) if(HAVE_LIBM) target_link_libraries (${exe_name} m) endif(HAVE_LIBM) if (HAVE_LIBSTAPI) target_link_libraries(${exe_name} stapilib) endif (HAVE_LIBSTAPI) if (HAVE_LIBSTAPI5) target_link_libraries(${exe_name} stapi5lib) endif (HAVE_LIBSTAPI5) add_dependencies (${exe_name} ${csncam} ${csreaders} ${csmodules}) #----------------------- specific options ------------------------------ if (USE_LIBRT_STATIC) else (USE_LIBRT_STATIC) if (NOT NCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD|Android)") target_link_libraries (${exe_name} rt) endif (NOT NCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD|Android)") endif (USE_LIBRT_STATIC) if (NCamOperatingSystem MATCHES "Linux") elseif (NCamOperatingSystem MATCHES "Mac OS X") if (NOT HAVE_PCSC EQUAL 0) FIND_LIBRARY (PCSC_LIBRARY PCSC) message (STATUS "PCSC Mac OS X found : ${PCSC_LIBRARY}") add_definitions ("-DWITH_PCSC=1") target_link_libraries ( ${exe_name} ${PCSC_LIBRARY}) set (HAVE_PCSC True) FIND_LIBRARY (IOKit_LIBRARY IOKit) target_link_libraries ( ${exe_name} ${IOKit_LIBRARY}) FIND_LIBRARY (CoreFoundation_LIBRARY CoreFoundation) target_link_libraries ( ${exe_name} ${CoreFoundation_LIBRARY}) else (NOT HAVE_PCSC EQUAL 0) message (STATUS "PCSC Mac OS X not found no pcsc support") endif (NOT HAVE_PCSC EQUAL 0) elseif (NCamOperatingSystem MATCHES "Tuxbox") elseif (NCamOperatingSystem MATCHES "TripleDragon") elseif (NCamOperatingSystem MATCHES "MT7620") elseif (NCamOperatingSystem MATCHES "SlugOS") elseif (NCamOperatingSystem MATCHES "OpenWRT") elseif (NCamOperatingSystem MATCHES "Fonera2") elseif (NCamOperatingSystem MATCHES "DIR-825") elseif (NCamOperatingSystem MATCHES "agv2+w") elseif (NCamOperatingSystem MATCHES "WRT54G") elseif (NCamOperatingSystem MATCHES "Amino") elseif (NCamOperatingSystem MATCHES "QboxHD") elseif (NCamOperatingSystem MATCHES "Windows/Cygwin") message (STATUS "Windows system PCSC : winscard.dll") target_link_libraries (${exe_name} -Wl,--enable-stdcall-fixup winscard) target_link_libraries (${exe_name} setupapi ) target_link_libraries (${exe_name} ole32) target_link_libraries (${exe_name} shell32) elseif (NCamOperatingSystem MATCHES "NeutrinoHD") target_link_libraries (${exe_name} rt nxp) elseif (NCamOperatingSystem MATCHES "NHD2") target_link_libraries (${exe_name} lnxcssUsr lnxscsUsr lnxnotifyqUsr lnxUKAL lnxplatUsr rt) elseif (NCamOperatingSystem MATCHES "AZBox") add_library(xcas STATIC IMPORTED) set_property(TARGET xcas PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/extapi/openxcas/libOpenXCASAPI.a) set (xcas_link "xcas") elseif (NCamOperatingSystem MATCHES "GXAPI") add_library(gx STATIC IMPORTED) set_property(TARGET gx PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/extapi/goceed/liboscam_gxapi.a) set (gx_link "gx") target_link_libraries (${exe_name} -L${CMAKE_CURRENT_SOURCE_DIR}/extapi/goceed -loscam_gxapi) elseif (NCamOperatingSystem MATCHES "SU980") target_link_libraries (${exe_name} rt entropic) elseif (NCamOperatingSystem MATCHES "WETEK") target_link_libraries (${exe_name} rt entropic) endif (NCamOperatingSystem MATCHES "Linux") target_link_libraries (${exe_name} ${libusb_link} ${rt_link} ${setupapi_link} ${ole32_link} ${shell32_link} ${pthread_link} ${dl_link} ${xcas_link} ${gx_link} ${libpcsc_link} ${ssl_link} ${crypto_link} ${libcurl_link}) #----------------------- put svnversion in the build ------------------------------ # at every target rebuild, we re-build the ncam.c compilation... # add the needed dependency add_dependencies (${exe_name} svnversion) add_dependencies (${csncam} svnversion-log) # how to re-build the files which printout the version add_custom_target ( svnversion ALL # touch ${CMAKE_CURRENT_SOURCE_DIR}/ncam.c ) add_custom_target ( svnversion-log ALL # touch ${CMAKE_CURRENT_SOURCE_DIR}/ncam-log.c ) execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --ncam-revision COMMAND tr -d '\n' OUTPUT_VARIABLE CS_REVISION) add_definitions ("-D'CS_REVISION=\"${CS_REVISION}\"'") execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --ncam-revision COMMAND cut -d "t" -f2 -s COMMAND tr -d '\n' OUTPUT_VARIABLE CS_GIT_VERSION) add_definitions ("-D'CS_GIT_VERSION=\"${CS_GIT_VERSION}\"'") execute_process (COMMAND date +'%d-%m-%Y' COMMAND tr -d '\n' OUTPUT_VARIABLE CS_DATE_BUILD) add_definitions ("-D'CS_DATE_BUILD=\"${CS_DATE_BUILD}\"'") if (NOT NCamOperatingSystem MATCHES "Android") execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine COMMAND tr -d '\n' OUTPUT_VARIABLE CS_TARGET) endif(NOT NCamOperatingSystem MATCHES "Android") add_definitions ("-D'CS_TARGET=\"${CS_TARGET}\"'") #----------------------- global compile and link options ------------------------------ #enable sse2 on x86 if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -msse3") endif (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") # disable warning about unused but set variables in gcc 4.6+ if (CMAKE_COMPILER_IS_GNUCC) execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION}) list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR) list(GET GCC_VERSION_COMPONENTS 0 GCC_MINOR) add_definitions ("-W -Wall ") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -pipe -ffunction-sections -fdata-sections -funroll-loops -fomit-frame-pointer -fno-schedule-insns") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2") set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ggdb") set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb") endif (CMAKE_COMPILER_IS_GNUCC) # some optimisations if (NCamOperatingSystem MATCHES "Mac OS X") if (SWVER GREATER 10.6) if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3) add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk") else (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3) add_definitions("-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk") endif (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3) elseif(SWVER LESS 10.7) add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk") endif (SWVER GREATER 10.6) endif (NCamOperatingSystem MATCHES "Mac OS X") # we don't want the '-rdynamic' in the link command set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # we want to strip if not Debug build if (NCamOperatingSystem MATCHES "Mac OS X") if (SWVER MATCHES "10.8") if (NOT CMAKE_BUILD_TYPE STREQUAL Debug) set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk") else (NOT CMAKE_BUILD_TYPE STREQUAL Debug) message (STATUS " building with debug") set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk") endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug) elseif (SWVER MATCHES "10.7") if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3) if (NOT CMAKE_BUILD_TYPE STREQUAL Debug) set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk") else (NOT CMAKE_BUILD_TYPE STREQUAL Debug) message (STATUS " building with debug") set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk") endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug) else(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3) if (NOT CMAKE_BUILD_TYPE STREQUAL Debug) set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk") else (NOT CMAKE_BUILD_TYPE STREQUAL Debug) message (STATUS " building with debug") set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk") endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug) endif(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3) elseif (SWVER MATCHES "10.6") if (NOT CMAKE_BUILD_TYPE STREQUAL Debug) set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk") else (NOT CMAKE_BUILD_TYPE STREQUAL Debug) message (STATUS " building with debug") set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk") endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug) endif (SWVER MATCHES "10.8") else (NCamOperatingSystem MATCHES "Mac OS X") if (NOT CMAKE_BUILD_TYPE STREQUAL Debug) set (CMAKE_EXE_LINKER_FLAGS "-s") else (NOT CMAKE_BUILD_TYPE STREQUAL Debug) message (STATUS " building with debug") set (CMAKE_EXE_LINKER_FLAGS "-ggdb") endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug) endif (NCamOperatingSystem MATCHES "Mac OS X") if (NCamOperatingSystem MATCHES "Windows/Cygwin") set (CMAKE_EXE_LINKER_FLAGS "--enable-stdcall-fixup") endif (NCamOperatingSystem MATCHES "Windows/Cygwin") #----------------------- subdirectory list smargo ------------------------------ if( HAVE_LIBRT OR HAVE_LIBRT_STATIC) if (HAVE_LIBUSB) add_subdirectory (utils) endif (HAVE_LIBUSB) endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC) #-------------------------------------------------------------------------------- if (NOT NCAmOperatingSystem MATCHES "Mac OS X") if (NOT DEFINED ENV{ANDROID_NDK}) if (NOT DEFINED ENV{ANDROID_STANDALONE_TOOLCHAIN}) if (WITH_SOFTCAM) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key) execute_process (COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key ${CMAKE_CURRENT_BINARY_DIR}/SoftCam.Key) else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key) execute_process (COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/SoftCam.Key) endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key) set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--format=binary -Wl,SoftCam.Key -Wl,--format=default") endif (WITH_SOFTCAM) endif (NOT DEFINED ENV{ANDROID_STANDALONE_TOOLCHAIN}) endif (NOT DEFINED ENV{ANDROID_NDK}) endif (NOT NCAmOperatingSystem MATCHES "Mac OS X") #----------------------- installation ----------------------------- file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/ncam.*") file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt") file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1") file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5") file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.ac" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.cert" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.conf" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.guess" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.ird" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.server" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.services" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.srvid" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/ncam.user") file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh" "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar") install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin) install (FILES ${config_files} DESTINATION etc COMPONENT config) install (FILES ${doc_files} DESTINATION share/doc/ncam COMPONENT doc) install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc) install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc) install (FILES ${example_files} DESTINATION share/doc/ncam/example COMPONENT doc) install (FILES ${monitor_files} DESTINATION share/doc/ncam/monitor COMPONENT doc) #----------------------- we can use CPack to build pacakges -------------------------- # get version from source file execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h OUTPUT_VARIABLE CS_VERSION) string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION}) string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION}) string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION}) string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION}) set (CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") # compute my filename set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_TARGET}") # wich archive we want to generate set (CPACK_GENERATOR "TGZ") # what to put in the archive set (CPACK_STRIP_FILES TRUE) set (CPACK_COMPONENTS_ALL bin)# config doc) # ok, we can now use CPack include (CPack) #----------------------- printout resume ----------------------------- message (STATUS "") message (STATUS " operating system: ${NCamOperatingSystem}") message (STATUS " target system: ${CS_TARGET}") message (STATUS " revision: ${CS_REVISION}") if (HAVE_LIBCRYPTO) if (STATIC_LIBCRYPTO) message (STATUS " use static libcrypto.") else (STATIC_LIBCRYPTO) message (STATUS " use system libcrypto functions") endif (STATIC_LIBCRYPTO) else (HAVE_LIBCRYPTO) message (STATUS " use built-in crypt functions") endif (HAVE_LIBCRYPTO) if (HAVE_PCSC) if (STATIC_LIBPCSC) message (STATUS " use static pcsc functions") else (STATIC_LIBPCSC) message (STATUS " use system pcsc functions") endif (STATIC_LIBPCSC) endif (HAVE_PCSC) if (HAVE_PTHREAD) message (STATUS " use system pthread functions") endif (HAVE_PTHREAD) if (HAVE_LIBUSB) if(STATIC_LIBUSB EQUAL 1) message (STATUS " You selected to enable static libusb") endif(STATIC_LIBUSB EQUAL 1) if(STATICLIBUSB AND NOT LIBUSBDIR) message (STATUS " use static libusb functions") else(STATICLIBUSB AND NOT LIBUSBDIR) if (LIBUSBDIR AND STATIC_LIBUSB EQUAL 0) message(STATUS " use system libusb from selected LIBUSBDIR functions") elseif (LIBUSBDIR AND STATIC_LIBUSB EQUAL 1) message(STATUS " use static libusb from selected LIBUSBDIR functions") elseif(LIBUSBDIR) message(STATUS " use system libusb from selected LIBUSBDIR functions") elseif(NOT LIBUSBDIR AND NOT STATIC_LIBUSB) message (STATUS " use system libusb functions") endif(LIBUSBDIR AND STATIC_LIBUSB EQUAL 0) endif(STATICLIBUSB AND NOT LIBUSBDIR) endif (HAVE_LIBUSB) if (HAVE_LIBCURL) if (STATIC_LIBCURL) message (STATUS " use static curl functions") else (STATIC_LIBCURL) message (STATUS " use system curl functions") endif (STATIC_LIBCURL) endif (HAVE_LIBCURL) if (WITH_EMU) message (STATUS " Compile with EMU support") if (WITH_SOFTCAM) message (STATUS " SoftCam.Key will be linked as well") endif (WITH_SOFTCAM) endif (WITH_EMU) message (STATUS "")