Skip to content

Commit 130791e

Browse files
committed
fix build on suse
1 parent 6f20af7 commit 130791e

File tree

8 files changed

+111
-44
lines changed

8 files changed

+111
-44
lines changed

CMakeLists.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# CMakeLists.txt
33
# top-level CMake input file
44
# ----------------------------------------------------------------------------
5-
cmake_minimum_required(VERSION 3.12)
5+
cmake_minimum_required(VERSION 3.15)
66
project(camera C CXX)
77

88

@@ -26,6 +26,7 @@ option(OUTPUT_TO_SRC_DIR "output binaries and libraries to source folder rather
2626

2727

2828

29+
2930
if(NOT CMAKE_BUILD_TYPE)
3031
message(STATUS "no build type specified defaulting to RelWithDebInfo")
3132
set(CMAKE_BUILD_TYPE RelWithDebInfo)
@@ -65,6 +66,31 @@ endif()
6566

6667
find_package(Threads)
6768

69+
70+
#both emulator and camerad actually depend on cfitsio and CCfits (one only by header)
71+
#so we need to do those finds here, not in camerad/CMakeLists.
72+
73+
#NOTE (by danw): strictly, the archon interface requires linking to cfitsio because
74+
#CCfits is included by archon.h. I'm not sure this is intentional.
75+
#Anyway, to reflect that I moved the public linkage of these packages down to the interface
76+
#target rather than camerad.
77+
78+
#cfitsio has provided a cmake config file for quite a long time
79+
#on some systems where include files are not in the default place, this will still find them
80+
#if it fails, we fall back to camerad previous behaviour, manually finding the library file ONLY
81+
#(and not bothering about includes if they're not in the right place)
82+
83+
84+
#for cfitsio and CCfits we now provide our own find module
85+
#this allows for systems with non-standard paths to
86+
#replace that find module without hacking our build system (e.g. fedora, suse, etc)
87+
88+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
89+
find_package(cfitsio REQUIRED)
90+
find_package(CCfits REQUIRED)
91+
92+
93+
6894
#no need for absolute paths here, they are by default relative to ${CMAKE_CURRENT_LIST_DIR}
6995
add_subdirectory(utils)
7096
add_subdirectory(common)

camerad/CMakeLists.txt

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cmake_minimum_required(VERSION 3.12)
77
include_directories(${CMAKE_SOURCE_DIR}/utils)
88
include_directories(${CMAKE_SOURCE_DIR}/common)
99

10+
1011
# ----------------------------------------------------------------------------
1112
# Setup for appropriate hardware interface...
1213
#
@@ -17,6 +18,8 @@ include_directories(${CMAKE_SOURCE_DIR}/common)
1718
# interface target for interfacing to appropriate hardware
1819
# ----------------------------------------------------------------------------
1920

21+
22+
2023
# ----------------------------------------------------------------------------
2124
# AstroCam ARC-64/66 PCI/e interfaces
2225
# ----------------------------------------------------------------------------
@@ -55,21 +58,18 @@ if (${INTERFACE_TYPE} STREQUAL "AstroCam")
5558
find_library(CARC_DEVICE "CArcDevice3.6" NAMES "libCArcDevice3.6.so" PATHS ${ARCAPI_DIR}/Release)
5659
find_library(CARC_FITS "CArcFitsFile3.6" NAMES "libCArcFitsFile3.6.so" PATHS ${ARCAPI_DIR}/Release)
5760

61+
add_library(interface STATIC ${INTERFACE_SOURCE})
62+
63+
5864
# ----------------------------------------------------------------------------
5965
# STA Archon interfaces
6066
# ----------------------------------------------------------------------------
6167

6268
elseif (${INTERFACE_TYPE} STREQUAL "Archon")
6369
message(STATUS "compiling for STA Archon")
64-
set(INTERFACE_TARGET archon)
6570
add_definitions(-Wall -ansi -O1 -Wno-variadic-macros -std=c++17 -ggdb)
6671
add_definitions(-DSTA_ARCHON)
67-
list(APPEND INTERFACE_SOURCE
68-
"archon.cpp"
69-
)
70-
list(APPEND INTERFACE_INCLUDES
71-
"${ARCHON_INCLUDE}"
72-
)
72+
list(APPEND INTERFACE_SOURCE "archon.cpp")
7373
add_library(interface STATIC "${INTERFACE_SOURCE}")
7474
if (${DETECTOR_TYPE} STREQUAL "Hxrg")
7575
message(STATUS "compiling for HXRG detector")
@@ -112,38 +112,15 @@ endif ()
112112

113113
# Now add the defined interface target:
114114
#
115-
add_library(${INTERFACE_TARGET} ${INTERFACE_SOURCE})
116-
target_include_directories(${INTERFACE_TARGET} PUBLIC ${INTERFACE_INCLUDES})
115+
target_link_libraries(interface PUBLIC cfitsio CCfits)
117116

118117

119-
add_library(camera camera.cpp)
120-
121-
# ----------------------------------------------------------------------------
122-
# External libraries, such as FITS, etc.
123-
# ----------------------------------------------------------------------------
124-
125-
#cfitsio has provided a cmake config file for quite a long time
126-
#on some systems where include files are not in the default place, this will still find them
127-
#if it fails, we fall back to camerad previous behaviour, manually finding the library file ONLY
128-
#(and not bothering about includes if they're not in the right place)
129-
find_package(cfitsio)
130-
131-
#the package file defines a cmake target rather than just the variables
132-
#that target will also have correct path to include files
133-
if(NOT TARGET cfitsio)
134-
message(STATUS "cfitsio package file not found, maybe an old old system. Try finding library manually")
135-
find_library(CFITS_LIB cfitsio NAMES libcfitsio PATHS /usr/local/lib)
136-
add_library(cfitsio UNKNOWN IMPORTED)
137-
set_target_properties(cfitsio PROPERTIES IMPORTED_LOCATION ${CFITS_LIB})
138-
endif()
139-
140-
#for CCfits, we now provide our own find module
141-
#this allows for systems with non-standard paths to
142-
#replace that find module without hacking our build system (e.g. fedora, suse, etc)
143118

119+
#Note from danw: I'm afraid camera.h technically includes CCfits, and so a public
120+
#dependency on those is needed
121+
add_library(camera camera.cpp)
122+
target_link_libraries(camera PUBLIC cfitsio CCfits)
144123

145-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
146-
find_package(CCfits REQUIRED)
147124

148125
find_package(Threads)
149126
add_executable(camerad camerad.cpp ${INTERFACE_INCLUDES})
@@ -158,15 +135,14 @@ target_link_libraries(camerad
158135
logentry
159136
common
160137
utilities
161-
${INTERFACE_TARGET}
138+
interface
162139
${CMAKE_THREAD_LIBS_INIT}
163140
cfitsio
164141
CCfits
165142
)
166143

167-
target_link_libraries(camerad ${CARC_BASE})
168-
target_link_libraries(camerad ${CARC_DEVICE})
169-
target_link_libraries(camerad ${CARC_FITS})
144+
target_link_libraries(camerad ${CARC_BASE} ${CARC_DEVICE} ${CARC_FITS})
145+
170146

171147
# ----------------------------------------------------------------------------
172148
# cURL is not used here, so it's not strictly required, but cfitsio can

camerad/archon.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ namespace Archon {
104104
}
105105
/**************** Archon::Interface::interface ******************************/
106106

107+
108+
/***Note from danw: I couldn't get this to link without adding a dummy method here no idea why
109+
**/
110+
111+
long Interface::power(std::string state_in, std::string& retstring)
112+
{
113+
return do_power(state_in, retstring);
114+
}
115+
116+
117+
107118
/***** Archon::Interface::do_power ******************************************/
108119
/**
109120
* @brief set/get the power state
@@ -876,7 +887,7 @@ namespace Archon {
876887
*
877888
*/
878889
long Interface::archon_cmd(std::string cmd) { // use this form when the calling
879-
std::string reply; // function doesn't need to look at the reply
890+
std::string reply; // function doesn't need to look at the reply
880891
return( archon_cmd(cmd, reply) );
881892
}
882893
long Interface::archon_cmd(std::string cmd, std::string &reply) {

cmake/FindCCfits.cmake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,27 @@ if(PKG_CONFIG_FOUND)
1111

1212
#for compatibility with camera-interface build system, alias the target to CCFITS_LIB as well
1313
add_library(CCfits ALIAS PkgConfig::CCFITS)
14+
set(CCfits_FOUND TRUE)
15+
1416
else()
1517
message(VERBOSE "no pkg-config, trying to locate CCfits manually")
1618
find_library(CCFITS_LIB CCfits NAMES libCCfits PATHS /usr/local/lib)
1719
message(VERBOSE "CCFITS library: ${CCFITS_LIB}")
20+
21+
find_path(CCFITS_INCLUDE CCfits.h PATHS /usr/local/lib)
22+
message(VERBOSE "CCFITS include: ${CCFITS_INCLUDE}")
23+
24+
get_filename_component(CCFITS_INCLUDE_DIR ${CCFITS_INCLUDE} DIRECTORY)
1825

1926
#note that we don't even bother to find non-standard include paths.
2027
#neither did the previous camera-interface build system.
2128
#If you have a non-standard include path, your CCfits installation should
2229
#have included a pkg-config file and mentioned it, or you should have dropped in your
2330
#own find module here. Good luck.
24-
add_library(CCfits UNKNOWN IMPORTED)
31+
add_library(CCfits UNKNOWNN IMPORTED)
2532
set_target_properties(CCfits PROPERTIES IMPORTED_LOCATION ${CCFITS_LIB})
33+
set_target_properties(CCfits PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CCFITS_INCLUDE_DIR})
34+
35+
set(CCfits_FOUND TRUE)
2636

2737
endif()

cmake/FindCCfits.cmake~

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#CCfits does by default provide a pkg-config recipe. Try this first, it's likely the best
2+
#however may not work on mac or windows
3+
4+
find_package(PkgConfig QUIET)

cmake/Findcfitsio.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#cfitsio *sometimes* includes a CMake config file. This is the worst of all possible worlds.
2+
#On systems where it doesn't, it will fall back to this find module
3+
4+
find_package(PkgConfig QUIET)
5+
if(PKG_CONFIG_FOUND)
6+
message(VERBOSE "found pkg-config, trying to locate cfitsio using it")
7+
pkg_check_modules(cfitsio cfitsio REQUIRED IMPORTED_TARGET)
8+
9+
add_library(cfitsio ALIAS PkgConfig::cfitsio)
10+
11+
get_target_property(PROP cfitsio INTERFACE_INCLUDE_DIRECTORIES)
12+
message(VERBOSE "iid: ${PROP}")
13+
message(VERBOSE "id: ${cfitsio_INCLUDE_DIRS}")
14+
15+
16+
17+
else()
18+
message(VERBOSE "no pkg-config, trying to locate cfitsio manually")
19+
find_library(CFITS_LIB cfitsio NAMES libcfitsio PATHS /usr/local/lib)
20+
add_library(cfitsio UNKNOWN IMPORTED)
21+
set_target_properties(cfitsio PROPERTIES IMPORTED_LOCATION ${CFITS_LIB})
22+
23+
find_path(FITSIO_INCLUDE fitsio.h)
24+
25+
message(VERBOSE "fitsio.h include location: ${FITSIO_INCLUDE}")
26+
27+
if(NOT FITSIO_INCLUDE)
28+
message(FATAL_ERROR "could not find fitsio.h file, build cannot continue!")
29+
endif()
30+
31+
get_filename_component(CFITSIO_INCLUDE_DIR ${FITSIO_INCLUDE} DIRECTORY)
32+
33+
set_target_properties(cfitsio PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CFITSIO_INCLUDE_DIR})
34+
35+
set(cfitsio_FOUND TRUE)
36+
37+
endif()

cmake/Findcfitsio.cmake~

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#cfitsio *sometimes* includes a CMake config file. This is the worst of all possible worlds.
2+
#On systems where it doesn't, it will fall back to this find module

emulator/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
cmake_minimum_required( VERSION 3.12 )
66
add_definitions( -Wall -Wno-variadic-macros)
77

8+
89
include_directories( ${CMAKE_SOURCE_DIR}/utils
910
${CMAKE_SOURCE_DIR}/camerad
1011
${CMAKE_SOURCE_DIR}/common )
@@ -20,8 +21,8 @@ if( ${INTERFACE_TYPE} STREQUAL "Archon" )
2021
)
2122

2223
add_library(${EMULATOR_TARGET} ${EMULATOR_SOURCE})
23-
24-
target_include_directories(${EMULATOR_TARGET} PUBLIC ${PROJECT_INCL_DIR})
24+
target_link_libraries(${EMULATOR_TARGET} PUBLIC cfitsio CCfits)
25+
target_link_libraries(emulatorInterface PUBLIC cfitsio CCfits)
2526

2627
add_executable(emulator emulator-server.cpp
2728
)

0 commit comments

Comments
 (0)