Folks,
I am using CMake to create 2 targets - a stand-alone executable and a
library that can be imported by Python. Both share most of the sources.
If I just specify them as two separate targets, each will compile all
the sources, so most of the source files end up compiled twice.
Is
Hi Nick,
What about creating a static library that would be linked against both the
executable and the library ?
Hth
Jc
On Mon, Apr 22, 2013 at 2:45 PM, Nick Gnedin ngne...@gmail.com wrote:
Folks,
I am using CMake to create 2 targets - a stand-alone executable and a
library that can be
A static lib does what you want and won't introduce any extra runtime
dependecies
On 22 Apr 2013 19:45, Nick Gnedin ngne...@gmail.com wrote:
Folks,
I am using CMake to create 2 targets - a stand-alone executable and a
library that can be imported by Python. Both share most of the sources. If
That doubles the size of the executable, because if I do something like
that:
ADD_LIBRARY(temp STATIC ${sources})
TARGET_LINK_LIBRARIES(temp outside_deps)
ADD_EXECUTABLE(code main.cpp)
TARGET_LINK_LIBRARIES(code temp)
then TARGET_LINK_LIBRARIES(...) also add outside_deps as link libraries
Nick Gnedin wrote:
That doubles the size of the executable, because if I do something like
that:
ADD_LIBRARY(temp STATIC ${sources})
TARGET_LINK_LIBRARIES(temp outside_deps)
ADD_EXECUTABLE(code main.cpp)
TARGET_LINK_LIBRARIES(code temp)
then TARGET_LINK_LIBRARIES(...) also add
...)
-Original Message-
From: Nick Gnedin ngne...@gmail.com
Cc: CMake ML cmake@cmake.org
Sent: Mon, Apr 22, 2013 2:55 pm
Subject: Re: [CMake] Sharing sources between two targets
That doubles the size of the executable, because if I do something like
that:
ADD_LIBRARY(temp STATIC ${sources
it. (Assuming a release build, where the linker leaves out what it
doesn't need...)
-Original Message-
From: Nick Gnedin ngne...@gmail.com
Cc: CMake ML cmake@cmake.org
Sent: Mon, Apr 22, 2013 2:55 pm
Subject: Re: [CMake] Sharing sources between two targets
That doubles the size
to use the same sources in multiple outputs, with different compile
options, I make a copy of the file (copy_if_different) into the binary, and
then specify that for the related projects.
EXECUTE_PROCESS(COMMAND cmake -E copy_if_different
${CMAKE_SOURCE_DIR}/${VECTLIB_SOURCES}