Skip to content

Commit

Permalink
cmake: move OS compatibility checks into subdirectories
Browse files Browse the repository at this point in the history
The top-level CMakeLists.txt shouldn't need to know these prerequisites
for each implementation.
  • Loading branch information
cimes-isi committed Aug 9, 2022
1 parent 1a3d4b6 commit d022fee
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 31 deletions.
39 changes: 15 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,31 158,22 @@ endfunction()

# Libraries

add_subdirectory(dummy)

if(UNIX)
add_subdirectory(shmem)
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
add_subdirectory(cray-pm)
add_subdirectory(ibmpowernv)
add_subdirectory(jetson)
add_subdirectory(msr)
add_subdirectory(odroid)
add_subdirectory(rapl)
add_subdirectory(raplcap-msr)
add_subdirectory(zcu102)
endif()

if(UNIX OR WIN32)
add_subdirectory(osp)
add_subdirectory(wattsup)
endif()
# Must be added before libraries that build shmem providers
add_subdirectory(shmem)

if(APPLE)
add_subdirectory(ipg)
endif()
# Please keep these in alphabetical order
add_subdirectory(cray-pm)
add_subdirectory(dummy)
add_subdirectory(ibmpowernv)
add_subdirectory(ipg)
add_subdirectory(jetson)
add_subdirectory(msr)
add_subdirectory(odroid)
add_subdirectory(osp)
add_subdirectory(rapl)
add_subdirectory(raplcap-msr)
add_subdirectory(wattsup)
add_subdirectory(zcu102)

if(NOT TARGET energymon-default AND NOT ${ENERGYMON_BUILD_DEFAULT} MATCHES "NONE")
message(FATAL_ERROR
Expand Down
4 changes: 4 additions & 0 deletions cray-pm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
return()
endif()

set(SNAME cray-pm)
set(LNAME energymon-cray-pm)
set(SOURCES ${LNAME}.c;
Expand Down
4 changes: 4 additions & 0 deletions ibmpowernv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
return()
endif()

set(SNAME ibmpowernv)
set(SNAME_POWER ibmpowernv-power)
set(LNAME energymon-ibmpowernv)
Expand Down
4 changes: 4 additions & 0 deletions ipg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT APPLE)
return()
endif()

set(SNAME ipg)
set(LNAME energymon-ipg)
set(SOURCES ${LNAME}.c;${ENERGYMON_UTIL})
Expand Down
4 changes: 4 additions & 0 deletions jetson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
return()
endif()

set(SNAME jetson)
set(LNAME energymon-jetson)
set(SOURCES ${LNAME}.c;${ENERGYMON_UTIL};${ENERGYMON_TIME_UTIL};util.c;ina3221.c;ina3221x.c)
Expand Down
4 changes: 4 additions & 0 deletions msr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
return()
endif()

set(SNAME msr)
set(LNAME energymon-msr)
set(SOURCES ${LNAME}.c;${ENERGYMON_UTIL})
Expand Down
4 changes: 4 additions & 0 deletions odroid/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
return()
endif()

set(SNAME odroid)
set(LNAME energymon-odroid)
set(SNAME_IOCTL odroid-ioctl)
Expand Down
4 changes: 4 additions & 0 deletions osp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT (UNIX OR WIN32))
return()
endif()

set(SNAME osp)
set(LNAME energymon-osp)
set(SNAME_POLLING osp-polling)
Expand Down
4 changes: 4 additions & 0 deletions rapl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
return()
endif()

set(SNAME rapl)
set(LNAME energymon-rapl)
set(SOURCES ${LNAME}.c;${ENERGYMON_UTIL})
Expand Down
4 changes: 4 additions & 0 deletions raplcap-msr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
return()
endif()

set(SNAME raplcap-msr)
set(LNAME energymon-raplcap-msr)
set(SOURCES ${LNAME}.c;${ENERGYMON_UTIL})
Expand Down
4 changes: 4 additions & 0 deletions shmem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT UNIX)
return()
endif()

set(SNAME shmem)
set(LNAME energymon-shmem)
set(EXAMPLE energymon-shmem-example)
Expand Down
10 changes: 3 additions & 7 deletions wattsup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 11,6 @@ endif()

# Libraries

if(UNIX)
add_subdirectory(dev)
endif()
if(UNIX OR WIN32)
add_subdirectory(libftdi)
add_subdirectory(libusb)
endif()
add_subdirectory(dev)
add_subdirectory(libftdi)
add_subdirectory(libusb)
4 changes: 4 additions & 0 deletions wattsup/dev/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT UNIX)
return()
endif()

set(SNAME wattsup)
set(LNAME energymon-wattsup)
set(SOURCES ../energymon-wattsup.c;wattsup-driver-dev.c;${ENERGYMON_UTIL};${ENERGYMON_TIME_UTIL})
Expand Down
4 changes: 4 additions & 0 deletions wattsup/libftdi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT (UNIX OR WIN32))
return()
endif()

set(SNAME wattsup-libftdi)
set(LNAME energymon-wattsup-libftdi)
set(SOURCES ../energymon-wattsup.c;wattsup-driver-libftdi.c;${ENERGYMON_UTIL};${ENERGYMON_TIME_UTIL})
Expand Down
4 changes: 4 additions & 0 deletions wattsup/libusb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT (UNIX OR WIN32))
return()
endif()

set(SNAME wattsup-libusb)
set(LNAME energymon-wattsup-libusb)
set(SOURCES ../energymon-wattsup.c;wattsup-driver-libusb.c;${ENERGYMON_UTIL};${ENERGYMON_TIME_UTIL})
Expand Down
4 changes: 4 additions & 0 deletions zcu102/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|Android")
return()
endif()

set(SNAME zcu102)
set(LNAME energymon-zcu102)
set(SOURCES ${LNAME}.c;${ENERGYMON_UTIL};${ENERGYMON_TIME_UTIL})
Expand Down

0 comments on commit d022fee

Please sign in to comment.