[CMake] Testing for a target broke for me
Williams, Norman K
norman-k-williams at uiowa.edu
Thu Dec 12 17:30:10 EST 2013
On 12/12/13 2:13 PM, "Richard Shaw" <hobbes1069 at gmail.com<mailto:hobbes1069 at gmail.com>> wrote:
Very interesting but not quite what I'm looking for, in this case the main CMakeLists.txt does actually build a project, I just need it to build wxWidgets first.
Well it's up to you but 'build X and then build Y' is the definition of how using ExternalProject work.
What you describe doesn't seem like it would ever work, because the CMake source code is evaluated at Configuration time, not compile time. How is wxWidgets a target? Do you have an ADD_CUSTOM_TARGET command somewhere? You might have had it accidentally work because of how variables persist between make/configure runs in CMakeCache.txt, but I don't see how it could ever be dependable or predictable.
if(BOOTSTRAP_WXWIDGETS AND NOT TARGET wxWidgets)
message("Build wxWidgets")
else()
message("Doing normal build")
endif()
The CMake code below would do what you want to do. It builds wxWindows, and then builds your project.
project(TWOSTAGE)
include(ExternalProject)
if(NOT BUILD_MY_PROJECT) # starts out un-set/false at top level build dir
include(cmake/BuildWxWidgets.cmake)
# your project builds in a subdirectory of the top level build dir
ExternalProject_add(MyActualProject
DOWNLOAD_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/MyActualProject-build
CMAKE_ARGS
-DBUILD_MY_PROJECT:BOOL=TRUE
<all relevant cmake args, including where to find wxWindows libs/include>
INSTALL_COMMAND "" # presumably you don't want to install immediately.
)
else()
<normal build stuff, depending on WxWidgets>
endif()
________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20131212/acbf7859/attachment-0001.htm>
More information about the CMake
mailing list