Skip to content

Commit

Permalink
Use a custom target for arith.h
Browse files Browse the repository at this point in the history
because including a file generated by a custom command in more
than one target may result in it being generated multiple times
in a parallel build which doesn't work reliably in msbuild (#62).
See also http://www.cmake.org/pipermail/cmake/2008-October/024492.html
  • Loading branch information
vitaut committed Aug 4, 2015
1 parent 4cdeeab commit 6710a59
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/asl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ else ()
endif ()
endif ()

set(ASL_CORE_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/details.c ${CMAKE_CURRENT_BINARY_DIR}/arith.h)
# Use a custom target for arith.h, because including a file generated by a custom
# command in more than one target may result in it being generated multiple times
# in a parallel build which doesn't work reliably in msbuild (#62).
# See also http://www.cmake.org/pipermail/cmake/2008-October/024492.html
add_custom_target(arith.h DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arith.h)

set(ASL_CORE_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/details.c)
add_prefix(ASL_CORE_SOURCES solvers/
errchk.h
jac2dim.h
Expand Down Expand Up @@ -205,11 +210,11 @@ endif ()
add_mp_library(asl-core OBJECT ${ASL_CORE_SOURCES}
COMPILE_DEFINITIONS ${ASL_COMPILE_DEFINITIONS}
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(asl-core arith.h)

# Public ASL headers.
set(ASL_HEADERS aslbuilder.h aslsolver.h aslexpr.h aslexpr-visitor.h
aslproblem.h aslinterface.h ${CMAKE_CURRENT_BINARY_DIR}/arith.h
${CMAKE_CURRENT_BINARY_DIR}/stdio1.h)
aslproblem.h aslinterface.h ${CMAKE_CURRENT_BINARY_DIR}/stdio1.h)
add_prefix(ASL_HEADERS solvers/
asl.h asl_pfg.h asl_pfgh.h avltree.h funcadd.h getstub.h jacpdim.h nlp.h
nlp2.h psinfo.h)
Expand All @@ -219,6 +224,7 @@ set(ASL_SOURCES
set(ASL_INCLUDE_DIRS solvers ${CMAKE_CURRENT_BINARY_DIR})
add_mp_library(asl-extra OBJECT ${ASL_SOURCES} ${ASL_HEADERS}
INCLUDE_DIRECTORIES ${ASL_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src)
add_dependencies(asl-extra arith.h)

add_mp_library(asl STATIC OBJECT_LIBRARIES asl-core asl-extra
LIBRARIES mp INCLUDE_DIRECTORIES ${ASL_INCLUDE_DIRS})
Expand Down Expand Up @@ -349,6 +355,7 @@ else ()
add_c_compiler_flags(asl-core -Wno-unused-result -Wno-parentheses)
endif ()

install(FILES ${ASL_HEADERS} solvers/opcode.hd solvers/r_opn.hd
DESTINATION include/asl)
install(FILES ${ASL_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/arith.h
solvers/opcode.hd solvers/r_opn.hd
DESTINATION include/asl)
install(TARGETS asl tableproxy DESTINATION lib RUNTIME DESTINATION bin)

0 comments on commit 6710a59

Please sign in to comment.