Apply modern compiler options
These are options used in other places that significantly reduce the
size of binaries, in this case, 6KB, or about 15% of the total
application size.
Also, it should be noted, because raw-peci is a c++ application, we need
to set the CMAK_CXX_FLAGS as well for them to be applied. Specific
flags enabled are in the patchset.
Tested: Code compiles
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I68c91fa6fede6ab9ae69c6f29a2537ee95584e0a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 398f396..63241c5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,22 +12,21 @@
set(
CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} \
--Wall \
--Wextra \
--Wcast-align \
--Wunused \
--Wconversion \
--Wsign-conversion \
--Wnull-dereference \
--Wdouble-promotion \
--Wformat=2 \
--Wno-unused-parameter \
--Werror \
--Wduplicated-cond \
--Wduplicated-branches \
--Wlogical-op \
-"
- )
+ -Wall \
+ -Wextra \
+ -Wcast-align \
+ -Wunused \
+ -Wconversion \
+ -Wsign-conversion \
+ -Wnull-dereference \
+ -Wdouble-promotion \
+ -Wformat=2 \
+ -Wno-unused-parameter \
+ -Werror \
+ -Wduplicated-cond \
+ -Wduplicated-branches \
+ -Wlogical-op \
+")
install(TARGETS peci DESTINATION lib)
install(FILES peci.h DESTINATION include)
@@ -42,6 +41,28 @@
ARCHIVE DESTINATION lib/static)
if(${DBUS_RAW_PECI})
+ set(
+ CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} \
+ -Wall \
+ -Wextra \
+ -Wcast-align \
+ -Wunused \
+ -Wconversion \
+ -Wsign-conversion \
+ -Wdouble-promotion \
+ -Wformat=2 \
+ -Wno-unused-parameter \
+ -Werror \
+ -Wduplicated-cond \
+ -Wduplicated-branches \
+ -Wlogical-op \
+ -Wno-psabi \
+ -fno-rtti \
+ ")
+ # This flag doesn't compile, but should be debuged in a future patchset
+ #-Wnull-dereference \
+
add_executable(raw-peci dbus_raw_peci.cpp)
add_dependencies(raw-peci peci)
@@ -53,6 +74,9 @@
add_definitions(-DBOOST_ALL_NO_LIB)
add_definitions(-DBOOST_NO_RTTI)
add_definitions(-DBOOST_NO_TYPEID)
+ add_definitions(-DBOOST_EXCEPTION_DISABLE)
+ add_definitions(-DBOOST_ASIO_DISABLE_THREADS)
+ add_definitions(-DBOOST_ASIO_NO_DEPRECATED)
target_link_libraries(raw-peci peci -lsystemd sdbusplus)
@@ -64,4 +88,4 @@
set(SERVICE_FILES ${PROJECT_SOURCE_DIR}/service_files/com.intel.peci.service)
install(FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
-endif()
\ No newline at end of file
+endif()