Skip to content

Commit

Permalink
Create libraries for yul-phaser and solc to avoid compiling their sou…
Browse files Browse the repository at this point in the history
…rces again for soltest
  • Loading branch information
cameel committed Jun 22, 2021
1 parent 9cf6021 commit afb8fb4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
11 changes: 7 additions & 4 deletions solc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
set(
sources
set(libsolcli_sources
CommandLineInterface.cpp CommandLineInterface.h
main.cpp
)

add_library(solcli ${libsolcli_sources})
target_link_libraries(solcli PUBLIC solidity Boost::boost Boost::program_options)

set(sources main.cpp)

add_executable(solc ${sources})
target_link_libraries(solc PRIVATE solidity Boost::boost Boost::program_options)
target_link_libraries(solc PRIVATE solcli)

include(GNUInstallDirs)
install(TARGETS solc DESTINATION "${CMAKE_INSTALL_BINDIR}")
Expand Down
19 changes: 1 addition & 18 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,6 @@ set(yul_phaser_sources
yulPhaser/ProgramCache.cpp
yulPhaser/Selections.cpp
yulPhaser/SimulationRNG.cpp

# FIXME: yul-phaser is not a library so I can't just add it to target_link_libraries().
# My current workaround is just to include its source files here but this introduces
# unnecessary duplication. Create a library or find a way to reuse the list in both places.
../tools/yulPhaser/AlgorithmRunner.cpp
../tools/yulPhaser/Common.cpp
../tools/yulPhaser/Chromosome.cpp
../tools/yulPhaser/FitnessMetrics.cpp
../tools/yulPhaser/GeneticAlgorithms.cpp
../tools/yulPhaser/Mutations.cpp
../tools/yulPhaser/PairSelections.cpp
../tools/yulPhaser/Phaser.cpp
../tools/yulPhaser/Population.cpp
../tools/yulPhaser/Program.cpp
../tools/yulPhaser/ProgramCache.cpp
../tools/yulPhaser/Selections.cpp
../tools/yulPhaser/SimulationRNG.cpp
)
detect_stray_source_files("${yul_phaser_sources}" "yulPhaser/")

Expand All @@ -193,7 +176,7 @@ add_executable(soltest ${sources}
${libsolidity_util_sources}
${yul_phaser_sources}
)
target_link_libraries(soltest PRIVATE libsolc yul solidity smtutil solutil Boost::boost yulInterpreter evmasm Boost::filesystem Boost::program_options Boost::unit_test_framework evmc)
target_link_libraries(soltest PRIVATE libsolc yul solidity smtutil solutil phaser Boost::boost yulInterpreter evmasm Boost::filesystem Boost::program_options Boost::unit_test_framework evmc)


# Special compilation flag for Visual Studio (version 2019 at least affected)
Expand Down
9 changes: 6 additions & 3 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ target_link_libraries(solidity-upgrade PRIVATE solidity Boost::boost Boost::prog
include(GNUInstallDirs)
install(TARGETS solidity-upgrade DESTINATION "${CMAKE_INSTALL_BINDIR}")

add_executable(yul-phaser
yulPhaser/main.cpp
set(libphaser_sources
yulPhaser/Common.h
yulPhaser/Common.cpp
yulPhaser/AlgorithmRunner.h
Expand Down Expand Up @@ -43,6 +42,10 @@ add_executable(yul-phaser
yulPhaser/SimulationRNG.h
yulPhaser/SimulationRNG.cpp
)
target_link_libraries(yul-phaser PRIVATE solidity Boost::filesystem Boost::program_options)
add_library(phaser ${libphaser_sources})
target_link_libraries(phaser PUBLIC solidity Boost::boost Boost::program_options)

add_executable(yul-phaser yulPhaser/main.cpp)
target_link_libraries(yul-phaser PRIVATE phaser)

install(TARGETS yul-phaser DESTINATION "${CMAKE_INSTALL_BINDIR}")

0 comments on commit afb8fb4

Please sign in to comment.