From afb8fb4927aa6318d16050db6868ae8c744c4211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 22 Jun 2021 17:42:44 +0200 Subject: [PATCH] Create libraries for yul-phaser and solc to avoid compiling their sources again for soltest --- solc/CMakeLists.txt | 11 +++++++---- test/CMakeLists.txt | 19 +------------------ tools/CMakeLists.txt | 9 ++++++--- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/solc/CMakeLists.txt b/solc/CMakeLists.txt index a94638090..73f4381c6 100644 --- a/solc/CMakeLists.txt +++ b/solc/CMakeLists.txt @@ -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}") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 035262d5a..da1cb6ced 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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/") @@ -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) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1d4daeac8..b442ba96a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -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 @@ -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}")