cmake: refactor common code with executables

This commit is contained in:
Ben Boeckel 2014-10-21 11:21:28 -04:00
parent 89cff7bddc
commit c773f465ca
5 changed files with 28 additions and 72 deletions

View file

@ -32,6 +32,30 @@ add_definitions(-DSTATICLIB)
# miniupnp changed their static define # miniupnp changed their static define
add_definitions(-DMINIUPNP_STATICLIB) add_definitions(-DMINIUPNP_STATICLIB)
function (bitmonero_add_executable name)
source_group("${name}"
FILES
${ARGN})
add_executable("${name}"
${ARGN})
target_link_libraries("${name}"
PRIVATE
${EXTRA_LIBRARIES})
set_property(TARGET "${name}"
PROPERTY
FOLDER "prog")
if (STATIC)
set_property(TARGET "${name}"
PROPERTY
LINK_SEARCH_START_STATIC 1)
set_property(TARGET "${name}"
PROPERTY
LINK_SEARCH_END_STATIC 1)
endif ()
endfunction ()
add_subdirectory(common) add_subdirectory(common)
add_subdirectory(crypto) add_subdirectory(crypto)
add_subdirectory(cryptonote_core) add_subdirectory(cryptonote_core)

View file

@ -31,12 +31,7 @@ set(connectivity_tool_sources
set(connectivity_tool_headers) set(connectivity_tool_headers)
source_group(connectivity-tool bitmonero_add_executable(connectivity_tool
FILES
${connectivity_tool_sources}
${connectivity_tool_headers})
add_executable(connectivity_tool
${connectivity_tool_sources} ${connectivity_tool_sources}
${connectivity_tool_headers}) ${connectivity_tool_headers})
target_link_libraries(connectivity_tool target_link_libraries(connectivity_tool
@ -48,15 +43,3 @@ target_link_libraries(connectivity_tool
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_REGEX_LIBRARY} ${Boost_REGEX_LIBRARY}
${Boost_SYSTEM_LIBRARY}) ${Boost_SYSTEM_LIBRARY})
set_property(TARGET connectivity_tool
PROPERTY
FOLDER "prog")
if (STATIC)
set_property(TARGET connectivity_tool
PROPERTY
LINK_SEARCH_START_STATIC 1)
set_property(TARGET connectivity_tool
PROPERTY
LINK_SEARCH_END_STATIC 1)
endif ()

View file

@ -48,12 +48,7 @@ set(daemon_headers
../p2p/p2p_protocol_defs.h ../p2p/p2p_protocol_defs.h
../p2p/stdafx.h) ../p2p/stdafx.h)
source_group(daemon bitmonero_add_executable(daemon
FILES
${daemon_sources}
${daemon_headers})
add_executable(daemon
${daemon_sources} ${daemon_sources}
${daemon_headers}) ${daemon_headers})
target_link_libraries(daemon target_link_libraries(daemon
@ -72,18 +67,6 @@ target_link_libraries(daemon
${EXTRA_LIBRARIES}) ${EXTRA_LIBRARIES})
add_dependencies(daemon add_dependencies(daemon
version) version)
set_property(TARGET daemon
PROPERTY
FOLDER "prog")
set_property(TARGET daemon set_property(TARGET daemon
PROPERTY PROPERTY
OUTPUT_NAME "bitmonerod") OUTPUT_NAME "bitmonerod")
if (STATIC)
set_property(TARGET daemon
PROPERTY
LINK_SEARCH_START_STATIC 1)
set_property(TARGET daemon
PROPERTY
LINK_SEARCH_END_STATIC 1)
endif ()

View file

@ -34,12 +34,7 @@ set(simpleminer_headers
simpleminer_protocol_defs.h simpleminer_protocol_defs.h
target_helper.h) target_helper.h)
source_group(simpleminer bitmonero_add_executable(simpleminer
FILES
${simpleminer_sources}
${simpleminer_headers})
add_executable(simpleminer
${simpleminer_sources} ${simpleminer_sources}
${simpleminer_headers}) ${simpleminer_headers})
target_link_libraries(simpleminer target_link_libraries(simpleminer
@ -52,15 +47,3 @@ target_link_libraries(simpleminer
${Boost_SYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY} ${Boost_THREAD_LIBRARY}
${EXTRA_LIBRARIES}) ${EXTRA_LIBRARIES})
set_property(TARGET simpleminer
PROPERTY
FOLDER "prog")
if (STATIC)
set_property(TARGET simpleminer
PROPERTY
LINK_SEARCH_START_STATIC 1)
set_property(TARGET simpleminer
PROPERTY
LINK_SEARCH_END_STATIC 1)
endif ()

View file

@ -34,12 +34,7 @@ set(simplewallet_headers
simplewallet.h simplewallet.h
password_container.h) password_container.h)
source_group(simplewallet bitmonero_add_executable(simplewallet
FILES
${simplewallet_sources}
${simplewallet_headers})
add_executable(simplewallet
${simplewallet_sources} ${simplewallet_sources}
${simplewallet_headers}) ${simplewallet_headers})
target_link_libraries(simplewallet target_link_libraries(simplewallet
@ -56,15 +51,3 @@ target_link_libraries(simplewallet
${EXTRA_LIBRARIES}) ${EXTRA_LIBRARIES})
add_dependencies(simplewallet add_dependencies(simplewallet
version) version)
set_property(TARGET simplewallet
PROPERTY
FOLDER "prog")
if (STATIC)
set_property(TARGET simplewallet
PROPERTY
LINK_SEARCH_START_STATIC 1)
set_property(TARGET simplewallet
PROPERTY
LINK_SEARCH_END_STATIC 1)
endif ()