Build fips_shared_support.c as part of libcrypto

This aligns with the generated build, where fips_shared_support.c is
part of crypto_sources, not the delocated part.

It is conceptually part of bcm, but our generated builds currently
only separate on basis of delocated/partial-linked vs. not delocated.

Bug: 542
Change-Id: Ib8de3fb0a7778c9000c3b4fca978d43cb9a29d12
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/67267
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index e064938..70dfdff 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -3,12 +3,9 @@
 if(FIPS_DELOCATE OR FIPS_SHARED)
   SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES EXTERNAL_OBJECT true)
   SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES GENERATED true)
-
-  set(
-    CRYPTO_FIPS_OBJECTS
-
-    fipsmodule/bcm.o
-  )
+  set(CRYPTO_FIPS_OBJECTS fipsmodule/bcm.o)
+else()
+  set(CRYPTO_FIPS_OBJECTS $<TARGET_OBJECTS:fipsmodule>)
 endif()
 
 set(
@@ -175,6 +172,7 @@
   evp/scrypt.c
   evp/sign.c
   ex_data.c
+  fipsmodule/fips_shared_support.c
   hpke/hpke.c
   hrss/hrss.c
   keccak/keccak.c
@@ -300,7 +298,6 @@
   x509/x509rset.c
   x509/x509spki.c
 
-  $<TARGET_OBJECTS:fipsmodule>
   ${CRYPTO_FIPS_OBJECTS}
 )
 if(OPENSSL_ASM)
diff --git a/crypto/fipsmodule/CMakeLists.txt b/crypto/fipsmodule/CMakeLists.txt
index 9ab3da3..239ebee 100644
--- a/crypto/fipsmodule/CMakeLists.txt
+++ b/crypto/fipsmodule/CMakeLists.txt
@@ -58,13 +58,7 @@
     message(FATAL_ERROR "Can't set both delocate and shared mode for FIPS build")
   endif()
 
-  add_library(
-    bcm_c_generated_asm
-
-    STATIC
-
-    bcm.c
-  )
+  add_library(bcm_c_generated_asm STATIC bcm.c)
   add_dependencies(bcm_c_generated_asm boringssl_prefix_symbols)
   target_include_directories(bcm_c_generated_asm PRIVATE ../../include)
   set_target_properties(bcm_c_generated_asm PROPERTIES COMPILE_OPTIONS "-S")
@@ -98,13 +92,7 @@
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
   )
 
-  add_library(
-    bcm_hashunset
-
-    STATIC
-
-    bcm-delocated.S
-  )
+  add_library(bcm_hashunset STATIC bcm-delocated.S)
   set_target_properties(bcm_hashunset PROPERTIES POSITION_INDEPENDENT_CODE ON)
   set_target_properties(bcm_hashunset PROPERTIES LINKER_LANGUAGE C)
 
@@ -121,40 +109,12 @@
   # CMakeLists.txt that defines it. Thus we have to wrap bcm.o in a custom target
   # so that crypto can depend on it.
   add_custom_target(bcm_o_target DEPENDS bcm.o)
-
-  add_library(
-    fipsmodule
-
-    OBJECT
-
-    fips_shared_support.c
-  )
-  add_dependencies(fipsmodule boringssl_prefix_symbols)
-  target_include_directories(fipsmodule PRIVATE ../../include)
-  set_target_properties(fipsmodule PROPERTIES LINKER_LANGUAGE C)
 elseif(FIPS_SHARED)
   if(NOT BUILD_SHARED_LIBS)
     message(FATAL_ERROR "FIPS_SHARED set but not BUILD_SHARED_LIBS")
   endif()
 
-  add_library(
-    fipsmodule
-
-    OBJECT
-
-    fips_shared_support.c
-  )
-  add_dependencies(fipsmodule boringssl_prefix_symbols)
-  target_include_directories(fipsmodule PRIVATE ../../include)
-
-  add_library(
-    bcm_library
-
-    STATIC
-
-    bcm.c
-    ${BCM_SOURCES_ASM_USED}
-  )
+  add_library(bcm_library STATIC bcm.c ${BCM_SOURCES_ASM_USED})
   add_dependencies(bcm_library boringssl_prefix_symbols)
   target_include_directories(bcm_library PRIVATE ../../include)
 
@@ -167,15 +127,7 @@
 
   add_custom_target(bcm_o_target DEPENDS bcm.o)
 else()
-  add_library(
-    fipsmodule
-
-    OBJECT
-
-    bcm.c
-    fips_shared_support.c
-    ${BCM_SOURCES_ASM_USED}
-  )
+  add_library(fipsmodule OBJECT bcm.c ${BCM_SOURCES_ASM_USED})
   add_dependencies(fipsmodule boringssl_prefix_symbols)
   target_include_directories(fipsmodule PRIVATE ../../include)
 endif()