Skip to content

Commit

Permalink
Cleanup cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Oct 7, 2023
1 parent e8be947 commit b5b845a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 164 deletions.
35 changes: 9 additions & 26 deletions api/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)

set(LIEF_C_INCLUDE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/LIEF.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/logging.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/types.h"
)

set(LIEF_C_SRC "${CMAKE_CURRENT_LIST_DIR}/logging.cpp")

if (LIEF_ELF)
include("${CMAKE_CURRENT_LIST_DIR}/ELF/CMakeLists.txt")
if(LIEF_ELF)
add_subdirectory(ELF)
endif()

if (LIEF_PE)
include("${CMAKE_CURRENT_LIST_DIR}/PE/CMakeLists.txt")
if(LIEF_PE)
add_subdirectory(PE)
endif()

if (LIEF_MACHO)
include("${CMAKE_CURRENT_LIST_DIR}/MachO/CMakeLists.txt")
if(LIEF_MACHO)
add_subdirectory(MachO)
endif()

source_group("Header Files\\C API" FILES ${LIEF_C_INCLUDE_FILES})

target_sources(LIB_LIEF PRIVATE "${LIEF_C_SRC}" ${LIEF_C_INCLUDE_FILES})

target_sources(LIB_LIEF PRIVATE logging.cpp)
target_include_directories(LIB_LIEF PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
52 changes: 9 additions & 43 deletions api/c/ELF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,10 @@
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
target_sources(LIB_LIEF PRIVATE
Symbol.cpp
Section.cpp
Segment.cpp
DynamicEntry.cpp
Header.cpp
Binary.cpp
EnumToString.cpp
utils.cpp
)

set(LIEF_C_ELF_SRC
"${CMAKE_CURRENT_LIST_DIR}/Symbol.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Segment.cpp"
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntry.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
"${CMAKE_CURRENT_LIST_DIR}/utils.cpp"
)


set(LIEF_API_C_ELF_INCLUDE_FILES_CPP
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntry.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Segment.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Symbol.hpp"
)

set(LIEF_API_C_ELF_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Binary.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/DynamicEntry.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/EnumToString.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Header.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Section.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Segment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Symbol.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/utils.h"
)

set(LIEF_C_ELF_INC "${LIEF_API_C_ELF_INCLUDE_FILES_C}" "${LIEF_API_C_ELF_INCLUDE_FILES_CPP}")

source_group("Source Files\\C API\\ELF" FILES ${LIEF_API_C_ELF_SRC})
source_group("Header Files\\C API\\ELF" FILES ${LIEF_C_ELF_INC})

target_sources(LIB_LIEF PRIVATE "${LIEF_C_ELF_SRC}" "${LIEF_C_ELF_INC}")
53 changes: 9 additions & 44 deletions api/c/MachO/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,10 @@
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
target_sources(LIB_LIEF PRIVATE
EnumToString.cpp
Parser.cpp
LoadCommand.cpp
Segment.cpp
Symbol.cpp
Section.cpp
Header.cpp
Binary.cpp
)

set(LIEF_API_C_MACHO_SRC
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Parser.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LoadCommand.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Segment.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Symbol.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
)


set(LIEF_API_C_MACHO_INCLUDE_FILES_CPP
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
"${CMAKE_CURRENT_LIST_DIR}/LoadCommand.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Segment.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Symbol.hpp"
)


set(LIEF_API_C_MACHO_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Binary.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/EnumToString.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Header.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/LoadCommand.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Section.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Segment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Symbol.h"
)


set(LIEF_C_MACHO_INC "${LIEF_API_C_MACHO_INCLUDE_FILES_C}" "${LIEF_API_C_MACHO_INCLUDE_FILES_CPP}")

source_group("Source Files\\C API\\MachO" FILES ${LIEF_API_C_MACHO_SRC})
source_group("Header Files\\C API\\MachO" FILES ${LIEF_C_MACHO_INC})

target_sources(LIB_LIEF PRIVATE "${LIEF_API_C_MACHO_SRC}" ${LIEF_C_MACHO_INC})
57 changes: 10 additions & 47 deletions api/c/PE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,11 @@
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
target_sources(LIB_LIEF PRIVATE
Binary.cpp
DosHeader.cpp
Header.cpp
OptionalHeader.cpp
Section.cpp
DataDirectory.cpp
EnumToString.cpp
Import.cpp
ImportEntry.cpp
)
set(LIEF_API_C_PE_SRC
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
"${CMAKE_CURRENT_LIST_DIR}/DosHeader.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
"${CMAKE_CURRENT_LIST_DIR}/OptionalHeader.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
"${CMAKE_CURRENT_LIST_DIR}/DataDirectory.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Import.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ImportEntry.cpp"
)


set(LIEF_API_C_PE_INCLUDE_FILES_CPP
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
"${CMAKE_CURRENT_LIST_DIR}/DataDirectory.hpp"
"${CMAKE_CURRENT_LIST_DIR}/DosHeader.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
"${CMAKE_CURRENT_LIST_DIR}/OptionalHeader.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Import.hpp"
"${CMAKE_CURRENT_LIST_DIR}/ImportEntry.hpp"
)

set(LIEF_API_C_PE_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Binary.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/DataDirectory.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/DosHeader.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/EnumToString.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Header.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/OptionalHeader.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Section.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Import.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/ImportEntry.h"
)


set(LIEF_C_PE_INC "${LIEF_API_C_PE_INCLUDE_FILES_C}" "${LIEF_API_C_PE_INCLUDE_FILES_CPP}")

source_group("Source Files\\C API\\PE" FILES ${LIEF_API_C_PE_SRC})
source_group("Header Files\\C API\\PE" FILES ${LIEF_C_PE_INC})

target_sources(LIB_LIEF PRIVATE "${LIEF_API_C_PE_SRC}" "${LIEF_C_PE_INC}")
8 changes: 4 additions & 4 deletions cmake/LIEFApi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ set(__add_lief_api ON)
# Python
# ------
if (LIEF_PYTHON_API)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/api/python")
add_subdirectory(api/python)
endif()

# C API
# -----
if(LIEF_C_API)
target_include_directories(LIB_LIEF
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api/c/include>")
target_include_directories(LIB_LIEF PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api/c/include>")

include("${CMAKE_CURRENT_SOURCE_DIR}/api/c/CMakeLists.txt")
add_subdirectory(api/c)
endif()

0 comments on commit b5b845a

Please sign in to comment.