diff options
author | Josh Blum <josh@joshknows.com> | 2011-02-17 12:35:01 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-02-17 12:35:01 -0800 |
commit | 8b0fbfcd12c7f58ad73678f72681c5f75c1d5880 (patch) | |
tree | 37d4a4c3e719d8e357a9c123e91874c6ab21a5b0 /host/lib | |
parent | e11ced6bab02d8f548f424e0687b81e73769b9a7 (diff) | |
download | uhd-8b0fbfcd12c7f58ad73678f72681c5f75c1d5880.tar.gz uhd-8b0fbfcd12c7f58ad73678f72681c5f75c1d5880.tar.bz2 uhd-8b0fbfcd12c7f58ad73678f72681c5f75c1d5880.zip |
uhd: use source properties to set flags and defs not globally, but only for the source
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/convert/CMakeLists.txt | 5 | ||||
-rw-r--r-- | host/lib/transport/CMakeLists.txt | 9 | ||||
-rw-r--r-- | host/lib/types/CMakeLists.txt | 15 | ||||
-rw-r--r-- | host/lib/types/time_spec.cpp | 16 | ||||
-rw-r--r-- | host/lib/utils/CMakeLists.txt | 18 |
5 files changed, 43 insertions, 20 deletions
diff --git a/host/lib/convert/CMakeLists.txt b/host/lib/convert/CMakeLists.txt index de9c660e1..abc9c2707 100644 --- a/host/lib/convert/CMakeLists.txt +++ b/host/lib/convert/CMakeLists.txt @@ -35,7 +35,10 @@ CHECK_INCLUDE_FILE_CXX(emmintrin.h HAVE_EMMINTRIN_H) UNSET(CMAKE_REQUIRED_FLAGS) IF(HAVE_EMMINTRIN_H) - ADD_DEFINITIONS(${EMMINTRIN_FLAGS}) + SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_sse2.cpp + PROPERTIES COMPILE_FLAGS ${EMMINTRIN_FLAGS} + ) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_sse2.cpp ) diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index a66a58d32..a98bcc14e 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -55,14 +55,19 @@ CHECK_INCLUDE_FILE_CXX(winsock2.h HAVE_WINSOCK2_H) IF(HAVE_IFADDRS_H) MESSAGE(STATUS " Interface address discovery supported through getifaddrs.") - ADD_DEFINITIONS(-DHAVE_IFADDRS_H) + SET(IF_ADDRS_DEFS HAVE_IFADDRS_H) ELSEIF(HAVE_WINSOCK2_H) MESSAGE(STATUS " Interface address discovery supported through SIO_GET_INTERFACE_LIST.") - ADD_DEFINITIONS(-DHAVE_WINSOCK2_H) + SET(IF_ADDRS_DEFS HAVE_WINSOCK2_H) ELSE(HAVE_IFADDRS_H) MESSAGE(STATUS " Interface address discovery not supported.") ENDIF(HAVE_IFADDRS_H) +SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/if_addrs.cpp + PROPERTIES COMPILE_DEFINITIONS "${IF_ADDRS_DEFS}" +) + ######################################################################## # Append to the list of sources for lib uhd ######################################################################## diff --git a/host/lib/types/CMakeLists.txt b/host/lib/types/CMakeLists.txt index ad625111e..957dfd345 100644 --- a/host/lib/types/CMakeLists.txt +++ b/host/lib/types/CMakeLists.txt @@ -58,19 +58,24 @@ CHECK_CXX_SOURCE_COMPILES(" IF(HAVE_CLOCK_GETTIME) MESSAGE(STATUS " High resolution timing supported through clock_gettime.") - ADD_DEFINITIONS(-DTIME_SPEC_USE_CLOCK_GETTIME) - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lrt") + SET(TIME_SPEC_DEFS HAVE_CLOCK_GETTIME) + LIBUHD_APPEND_LIBS("-lrt") ELSEIF(HAVE_MACH_ABSOLUTE_TIME) MESSAGE(STATUS " High resolution timing supported through mach_absolute_time.") - ADD_DEFINITIONS(-DTIME_SPEC_USE_MACH_ABSOLUTE_TIME) + SET(TIME_SPEC_DEFS HAVE_MACH_ABSOLUTE_TIME) ELSEIF(HAVE_QUERY_PERFORMANCE_COUNTER) MESSAGE(STATUS " High resolution timing supported through QueryPerformanceCounter.") - ADD_DEFINITIONS(-DTIME_SPEC_USE_QUERY_PERFORMANCE_COUNTER) + SET(TIME_SPEC_DEFS HAVE_QUERY_PERFORMANCE_COUNTER) ELSE() MESSAGE(STATUS " High resolution timing supported though microsec_clock.") - ADD_DEFINITIONS(-DTIME_SPEC_USE_MICROSEC_CLOCK) + SET(TIME_SPEC_DEFS HAVE_MICROSEC_CLOCK) ENDIF() +SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/time_spec.cpp + PROPERTIES COMPILE_DEFINITIONS "${TIME_SPEC_DEFS}" +) + ######################################################################## # This file included, use CMake directory variables ######################################################################## diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp index 4a41f0fb9..a785332c2 100644 --- a/host/lib/types/time_spec.cpp +++ b/host/lib/types/time_spec.cpp @@ -36,26 +36,26 @@ static UHD_INLINE time_spec_t time_spec_t_from_counts(intmax_t counts, intmax_t return time_spec_t(time_t(divres.quot), double(divres.rem)/freq); } -#ifdef TIME_SPEC_USE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME #include <time.h> time_spec_t time_spec_t::get_system_time(void){ timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return time_spec_t(ts.tv_sec, ts.tv_nsec, 1e9); } -#endif /* TIME_SPEC_USE_CLOCK_GETTIME */ +#endif /* HAVE_CLOCK_GETTIME */ -#ifdef TIME_SPEC_USE_MACH_ABSOLUTE_TIME +#ifdef HAVE_MACH_ABSOLUTE_TIME #include <mach/mach_time.h> time_spec_t time_spec_t::get_system_time(void){ mach_timebase_info_data_t info; mach_timebase_info(&info); intmax_t nanosecs = mach_absolute_time()*info.numer/info.denom; return time_spec_t_from_counts(nanosecs, intmax_t(1e9)); } -#endif /* TIME_SPEC_USE_MACH_ABSOLUTE_TIME */ +#endif /* HAVE_MACH_ABSOLUTE_TIME */ -#ifdef TIME_SPEC_USE_QUERY_PERFORMANCE_COUNTER +#ifdef HAVE_QUERY_PERFORMANCE_COUNTER #include <Windows.h> time_spec_t time_spec_t::get_system_time(void){ LARGE_INTEGER counts, freq; @@ -63,10 +63,10 @@ time_spec_t time_spec_t::get_system_time(void){ QueryPerformanceFrequency(&freq); return time_spec_t_from_counts(counts.QuadPart, freq.QuadPart); } -#endif /* TIME_SPEC_USE_QUERY_PERFORMANCE_COUNTER */ +#endif /* HAVE_QUERY_PERFORMANCE_COUNTER */ -#ifdef TIME_SPEC_USE_MICROSEC_CLOCK +#ifdef HAVE_MICROSEC_CLOCK #include <boost/date_time/posix_time/posix_time.hpp> namespace pt = boost::posix_time; time_spec_t time_spec_t::get_system_time(void){ @@ -78,7 +78,7 @@ time_spec_t time_spec_t::get_system_time(void){ double(pt::time_duration::ticks_per_second()) ); } -#endif /* TIME_SPEC_USE_MICROSEC_CLOCK */ +#endif /* HAVE_MICROSEC_CLOCK */ /*********************************************************************** * Time spec constructors diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index 5fa5b4d6d..743528189 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -48,14 +48,19 @@ CHECK_CXX_SOURCE_COMPILES(" IF(HAVE_PTHREAD_SETSCHEDPARAM) MESSAGE(STATUS " Priority scheduling supported through pthread_setschedparam.") - ADD_DEFINITIONS(-DHAVE_PTHREAD_SETSCHEDPARAM) + SET(THREAD_PRIO_DEFS HAVE_PTHREAD_SETSCHEDPARAM) ELSEIF(HAVE_WIN_SETTHREADPRIORITY) MESSAGE(STATUS " Priority scheduling supported through windows SetThreadPriority.") - ADD_DEFINITIONS(-DHAVE_WIN_SETTHREADPRIORITY) + SET(THREAD_PRIO_DEFS HAVE_WIN_SETTHREADPRIORITY) ELSE(HAVE_PTHREAD_SETSCHEDPARAM) MESSAGE(STATUS " Priority scheduling not supported.") ENDIF(HAVE_PTHREAD_SETSCHEDPARAM) +SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/thread_priority.cpp + PROPERTIES COMPILE_DEFINITIONS "${THREAD_PRIO_DEFS}" +) + ######################################################################## # Setup defines for module loading ######################################################################## @@ -68,15 +73,20 @@ CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H) IF(HAVE_DLFCN_H) MESSAGE(STATUS " Module loading supported through dlopen.") - ADD_DEFINITIONS(-DHAVE_DLFCN_H) + SET(LOAD_MODULES_DEFS HAVE_DLFCN_H) LIBUHD_APPEND_LIBS(${CMAKE_DL_LIBS}) ELSEIF(HAVE_WINDOWS_H) MESSAGE(STATUS " Module loading supported through LoadLibrary.") - ADD_DEFINITIONS(-DHAVE_WINDOWS_H) + SET(LOAD_MODULES_DEFS HAVE_WINDOWS_H) ELSE(HAVE_DLFCN_H) MESSAGE(STATUS " Module loading not supported.") ENDIF(HAVE_DLFCN_H) +SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/load_modules.cpp + PROPERTIES COMPILE_DEFINITIONS "${LOAD_MODULES_DEFS}" +) + ######################################################################## # Append sources ######################################################################## |