-
Notifications
You must be signed in to change notification settings - Fork 106
Add cmake support #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||||||
| cmake_minimum_required(VERSION 3.6) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| project (elfin) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| set(CMAKE_CXX_STANDARD 17) | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| add_subdirectory(elf elfdir) | ||||||||||||||||||||||
| add_subdirectory(dwarf dwarfdir) | ||||||||||||||||||||||
| add_subdirectory(examples examplesdir) | ||||||||||||||||||||||
|
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding an immediate subdirectory in the source tree as a different directory in the build directory is not necessary.
Suggested change
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||||||
| cmake_minimum_required(VERSION 3.6) | ||||||||||
|
|
||||||||||
| project(dwarf) | ||||||||||
|
|
||||||||||
| set(dwarfH ${CMAKE_CURRENT_LIST_DIR}/dwarf++.hh) | ||||||||||
| set(dataH ${CMAKE_CURRENT_LIST_DIR}/data.hh) | ||||||||||
|
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| set(to_string_src ${CMAKE_CURRENT_BINARY_DIR}/to_string.cc) | ||||||||||
| set(configured_to_string_script ${CMAKE_CURRENT_BINARY_DIR}/create_to_string_code.sh) | ||||||||||
|
|
||||||||||
| configure_file(create_to_string_code.sh ${configured_to_string_script}) | ||||||||||
|
|
||||||||||
| add_custom_command( | ||||||||||
| OUTPUT ${to_string_src} | ||||||||||
| COMMAND bash ${configured_to_string_script} ${dwarfH} ${dataH} ${to_string_src}) | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bash is not really cross platform (it is less often available on Windows then python). See conan-io/conan-center-index#3283 for an example. |
||||||||||
| add_custom_target(to_string_target DEPENDS ${to_string_src}) | ||||||||||
|
|
||||||||||
| add_library(dwarf dwarf.cc cursor.cc die.cc value.cc abbrev.cc | ||||||||||
| expr.cc rangelist.cc line.cc attrs.cc | ||||||||||
| die_str_map.cc elf.cc ${to_string_src}) | ||||||||||
| target_include_directories(dwarf PUBLIC ${CMAKE_CURRENT_LIST_DIR}) | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| target_link_libraries(dwarf elf) | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # $1 is dwarf++.hh | ||
| # $2 is data.hh | ||
| # $3 is to_string.cc | ||
|
|
||
| ( | ||
| echo "// Automatically generated by make at $(date)" | ||
| echo "// DO NOT EDIT" | ||
| echo | ||
| echo '#include "internal.hh"' | ||
| echo | ||
| echo DWARFPP_BEGIN_NAMESPACE | ||
| echo | ||
|
|
||
| python3 ${CMAKE_CURRENT_LIST_DIR}/../elf/enum-print.py < $1 | ||
| python3 ${CMAKE_CURRENT_LIST_DIR}/../elf/enum-print.py -s _ -u --hex -x hi_user -x lo_user < $2 | ||
|
|
||
| echo DWARFPP_END_NAMESPACE | ||
| ) > $3 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||
| cmake_minimum_required(VERSION 3.6) | ||||||
|
|
||||||
| project(elf) | ||||||
|
|
||||||
| set(toStringInputHeader ${CMAKE_CURRENT_LIST_DIR}/data.hh) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| set(to_string_src ${CMAKE_CURRENT_BINARY_DIR}/to_string.cc) | ||||||
| set(configured_to_string_script ${CMAKE_CURRENT_BINARY_DIR}/create_to_string_code.sh) | ||||||
|
|
||||||
| configure_file(create_to_string_code.sh ${configured_to_string_script}) | ||||||
|
|
||||||
| add_custom_command( | ||||||
| OUTPUT ${to_string_src} | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark as the dwarf library. |
||||||
| COMMAND bash ${configured_to_string_script} ${toStringInputHeader} ${to_string_src}) | ||||||
| add_custom_target(elf_to_string_target DEPENDS ${to_string_src}) | ||||||
| add_library(elf elf.cc mmap_loader.cc ${to_string_src}) | ||||||
| add_dependencies(elf elf_to_string_target) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This dependency (or |
||||||
| target_include_directories(elf PUBLIC ${CMAKE_CURRENT_LIST_DIR}) | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| ( | ||
| echo "// Automatically generated by make at $(date)" | ||
| echo "// DO NOT EDIT" | ||
| echo | ||
| echo '#include "data.hh"' | ||
| echo '#include "to_hex.hh"' | ||
| echo | ||
| echo 'ELFPP_BEGIN_NAMESPACE' | ||
| echo | ||
|
|
||
| python3 ${CMAKE_CURRENT_LIST_DIR}/enum-print.py -u --hex --no-type --mask shf --mask pf \ | ||
| -x loos -x hios -x loproc -x hiproc < $1 | ||
|
|
||
| echo ELFPP_END_NAMESPACE | ||
| ) > $2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Automatically generated by make at ${currentTime} | ||
| // DO NOT EDIT | ||
|
|
||
| #include "data.hh" | ||
| #include "to_hex.hh" | ||
|
|
||
| ELFPP_BEGIN_NAMESPACE | ||
|
|
||
| ${to_string_cc_contents} | ||
|
|
||
| ELFPP_END_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| cmake_minimum_required(VERSION 3.6) | ||
|
|
||
| project(libelfinexamples) | ||
|
|
||
| add_executable(dump-lines dump-lines.cc) | ||
| target_link_libraries(dump-lines dwarf) | ||
|
|
||
| add_executable(dump-sections dump-sections.cc) | ||
| target_link_libraries(dump-sections dwarf) | ||
|
|
||
| add_executable(dump-segments dump-segments.cc) | ||
| target_link_libraries(dump-segments dwarf) | ||
|
|
||
| add_executable(dump-syms dump-syms.cc) | ||
| target_link_libraries(dump-syms dwarf) | ||
|
|
||
| add_executable(dump-tree dump-tree.cc) | ||
| target_link_libraries(dump-tree dwarf) | ||
|
|
||
| add_executable(find-pc find-pc.cc) | ||
| target_link_libraries(find-pc dwarf) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| #include "elf++.hh" | ||
| #include "dwarf++.hh" | ||
|
|
||
| #include <errno.h> | ||
| #include <fcntl.h> | ||
| #include <inttypes.h> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| #include "elf++.hh" | ||
| #include "dwarf++.hh" | ||
|
|
||
| #include <errno.h> | ||
| #include <fcntl.h> | ||
| #include <inttypes.h> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be 11, not 17