@@ -17,6 +17,8 @@ option(INFOWARE_USE_OPENCL "Add public, transitive define to infoware to use Ope
17
17
18
18
option (INFOWARE_USE_X11 "Add public, transitive define to infoware to use X11 for display detection." OFF )
19
19
20
+ option (INFOWARE_USE_PCIIDS "Want PCI IDs. If disabled, the PCI ID database will not be compiled, and the pci.hpp API will be unimplemented." ON )
21
+
20
22
option (INFOWARE_EXAMPLES "Add infoware examples to the build." OFF )
21
23
option (INFOWARE_TESTS "Input tests for infoware." OFF )
22
24
@@ -91,67 +93,71 @@ if(BUILD_SHARED_LIBS) # Controls add_library() w/o explicit mode
91
93
target_compile_definitions (infoware PUBLIC INFOWARE_DLL=1 )
92
94
endif ()
93
95
94
- if (NOT Git_FOUND ) # Could be pre-injected
95
- find_package (Git )
96
- endif ()
96
+ if (INFOWARE_USE_PCIIDS )
97
+ target_compile_definitions (infoware PRIVATE INFOWARE_USE_PCIIDS )
97
98
98
- set (INFOWARE_PCI_DATA_DIR infoware_generated CACHE PATH "Output directory for the PCI ids generator" )
99
- set (INFOWARE_PCI_DATA_HPP pci_data.hpp )
100
- set (INFOWARE_PCI_DATA_GEN "${INFOWARE_PCI_DATA_DIR} /${INFOWARE_PCI_DATA_HPP} " )
101
- set (infoware_pci_ids_error "\
102
- The pci.ids file, downloadable from https://github.com/pciutils/pciids or http://pci-ids.ucw.cz, is required for building infoware, \
103
- and cloned automatically from that GitHub repository by default.\n\
104
- To use a local copy, set INFOWARE_PCI_IDS_PATH to its location." )
105
- if (NOT CMAKE_CROSSCOMPILING )
106
- if (INFOWARE_PCI_IDS_PATH )
107
- if (NOT EXISTS "${INFOWARE_PCI_IDS_PATH} " )
108
- message (WARNING "The specified pci.ids file INFOWARE_PCI_IDS_PATH=${INFOWARE_PCI_IDS_PATH} doesn't seem to exist." )
109
- endif ()
110
- set (infoware_pci_ids_file "${INFOWARE_PCI_IDS_PATH} " )
111
- elseif (NOT Git_FOUND )
112
- message (SEND_ERROR "Couldn't find a usable git executable in the environment, and the CMake variable INFOWARE_PCI_IDS_PATH is empty.\n ${infoware_pci_ids_error} " )
113
- else ()
114
- # Thanks, @griwes
115
- set (infoware_pci_ids_file "${CMAKE_CURRENT_BINARY_DIR} /pciids/pci.ids" )
116
- if (EXISTS "${infoware_pci_ids_file} " )
117
- execute_process (COMMAND "${GIT_EXECUTABLE} " remote set -url origin "${INFOWARE_PCI_IDS_REPOSITORY} "
118
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /pciids" )
119
- execute_process (COMMAND "${GIT_EXECUTABLE} " pull
120
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /pciids"
121
- RESULT_VARIABLE infoware_git_pciids_clone_err )
99
+ if (NOT Git_FOUND ) # Could be pre-injected
100
+ find_package (Git )
101
+ endif ()
102
+
103
+ set (INFOWARE_PCI_DATA_DIR infoware_generated CACHE PATH "Output directory for the PCI ids generator" )
104
+ set (INFOWARE_PCI_DATA_HPP pci_data.hpp )
105
+ set (INFOWARE_PCI_DATA_GEN "${INFOWARE_PCI_DATA_DIR} /${INFOWARE_PCI_DATA_HPP} " )
106
+ set (infoware_pci_ids_error "\
107
+ The pci.ids file, downloadable from https://github.com/pciutils/pciids or http://pci-ids.ucw.cz, is required for building infoware, \
108
+ and cloned automatically from that GitHub repository by default.\n\
109
+ To use a local copy, set INFOWARE_PCI_IDS_PATH to its location." )
110
+ if (NOT CMAKE_CROSSCOMPILING )
111
+ if (INFOWARE_PCI_IDS_PATH )
112
+ if (NOT EXISTS "${INFOWARE_PCI_IDS_PATH} " )
113
+ message (WARNING "The specified pci.ids file INFOWARE_PCI_IDS_PATH=${INFOWARE_PCI_IDS_PATH} doesn't seem to exist." )
114
+ endif ()
115
+ set (infoware_pci_ids_file "${INFOWARE_PCI_IDS_PATH} " )
116
+ elseif (NOT Git_FOUND )
117
+ message (SEND_ERROR "Couldn't find a usable git executable in the environment, and the CMake variable INFOWARE_PCI_IDS_PATH is empty.\n ${infoware_pci_ids_error} " )
122
118
else ()
123
- execute_process (COMMAND "${GIT_EXECUTABLE} " clone "${INFOWARE_PCI_IDS_REPOSITORY} " -- pciids
124
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} "
125
- RESULT_VARIABLE infoware_git_pciids_clone_err )
119
+ # Thanks, @griwes
120
+ set (infoware_pci_ids_file "${CMAKE_CURRENT_BINARY_DIR} /pciids/pci.ids" )
121
+ if (EXISTS "${infoware_pci_ids_file} " )
122
+ execute_process (COMMAND "${GIT_EXECUTABLE} " remote set -url origin "${INFOWARE_PCI_IDS_REPOSITORY} "
123
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /pciids" )
124
+ execute_process (COMMAND "${GIT_EXECUTABLE} " pull
125
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /pciids"
126
+ RESULT_VARIABLE infoware_git_pciids_clone_err )
127
+ else ()
128
+ execute_process (COMMAND "${GIT_EXECUTABLE} " clone "${INFOWARE_PCI_IDS_REPOSITORY} " -- pciids
129
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} "
130
+ RESULT_VARIABLE infoware_git_pciids_clone_err )
131
+ endif ()
132
+ if (infoware_git_pciids_clone_err )
133
+ message (SEND_ERROR "Cloning/pulling pciids repository from ${INFOWARE_PCI_IDS_REPOSITORY} failed with ${infoware_git_pciids_clone_err} .\n ${infoware_pci_ids_error} " )
134
+ endif ()
126
135
endif ()
127
- if (infoware_git_pciids_clone_err )
128
- message (SEND_ERROR "Cloning/pulling pciids repository from ${INFOWARE_PCI_IDS_REPOSITORY} failed with ${infoware_git_pciids_clone_err} .\n ${infoware_pci_ids_error} " )
129
- endif ()
130
- endif ()
131
136
132
- add_executable (infoware_pci_generator tools/pci_generator.cpp )
133
- set_target_properties (infoware_pci_generator PROPERTIES CXX_STANDARD 14
134
- CXX_STANDARD_REQUIRED ON
135
- CXX_EXTENSIONS OFF )
136
-
137
- add_custom_command (OUTPUT ${INFOWARE_PCI_DATA_GEN}
138
- COMMAND ${CMAKE_COMMAND} -E make_directory "${INFOWARE_PCI_DATA_DIR} "
139
- COMMAND $< TARGET_FILE:infoware_pci_generator> "${infoware_pci_ids_file} " > "${INFOWARE_PCI_DATA_GEN} "
140
- DEPENDS "${infoware_pci_ids_file} "
141
- COMMENT "Generating ${INFOWARE_PCI_DATA_HPP} " )
142
- add_custom_target (infoware_generate_pcis DEPENDS "${INFOWARE_PCI_DATA_GEN} " )
143
- else ()
144
- include (ExternalProject )
145
- ExternalProject_Add (infoware_generate_pcis
146
- SOURCE_DIR ${CMAKE_SOURCE_DIR}
147
- PREFIX ${CMAKE_BINARY_DIR} /pci_generator
148
- BINARY_DIR ${CMAKE_BINARY_DIR} /pci_generator
149
- BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target infoware_generate_pcis
150
- INSTALL_COMMAND ""
151
- BUILD_ALWAYS ON
152
- CMAKE_ARGS -DINFOWARE_PCI_DATA_DIR:PATH=${CMAKE_BINARY_DIR}/${INFOWARE_PCI_DATA_DIR} )
153
- endif ()
154
- add_dependencies (infoware infoware_generate_pcis )
137
+ add_executable (infoware_pci_generator tools/pci_generator.cpp )
138
+ set_target_properties (infoware_pci_generator PROPERTIES CXX_STANDARD 14
139
+ CXX_STANDARD_REQUIRED ON
140
+ CXX_EXTENSIONS OFF )
141
+
142
+ add_custom_command (OUTPUT ${INFOWARE_PCI_DATA_GEN}
143
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${INFOWARE_PCI_DATA_DIR} "
144
+ COMMAND $< TARGET_FILE:infoware_pci_generator> "${infoware_pci_ids_file} " > "${INFOWARE_PCI_DATA_GEN} "
145
+ DEPENDS "${infoware_pci_ids_file} "
146
+ COMMENT "Generating ${INFOWARE_PCI_DATA_HPP} " )
147
+ add_custom_target (infoware_generate_pcis DEPENDS "${INFOWARE_PCI_DATA_GEN} " )
148
+ else ()
149
+ include (ExternalProject )
150
+ ExternalProject_Add (infoware_generate_pcis
151
+ SOURCE_DIR ${CMAKE_SOURCE_DIR}
152
+ PREFIX ${CMAKE_BINARY_DIR} /pci_generator
153
+ BINARY_DIR ${CMAKE_BINARY_DIR} /pci_generator
154
+ BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target infoware_generate_pcis
155
+ INSTALL_COMMAND ""
156
+ BUILD_ALWAYS ON
157
+ CMAKE_ARGS -DINFOWARE_PCI_DATA_DIR:PATH=${CMAKE_BINARY_DIR}/${INFOWARE_PCI_DATA_DIR} )
158
+ endif ()
159
+ add_dependencies (infoware infoware_generate_pcis )
160
+ endif (INFOWARE_USE_PCIIDS )
155
161
156
162
157
163
if (MSVC )
0 commit comments